Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening documents in new instance of word (97)

    I am sorry if this has come up before but did not know what to search on.

    I have written a word template program which opens different documents, dependent on the database and the users selections from the user forms. This application also removes all menu bars and displays a program specific menu.

    All works fine until a user double clicks a word attachment in an email on in explorer, when the user does this it opens the document in my application window, which is actually word, though they can not do anything with it because I have removed all the menu items. The user must close the whole application to get rid of this document. Is there some way that I can change a setting so that all word documents open in a new instance of word, rather than my application?

    I hope you understand this, sorry I have not done alot of word programming.

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Opening documents in new instance of word (97)

    The only way I can think of to manage this would be for you to enable and disable the toolbars depending on whether the current document is a user selected one or your application. You will need to use the DocumentChange event to manage this, have a look at <post#=203498>post 203498</post#> for some example code.

    StuartR

  3. #3
    Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening documents in new instance of word (97)

    Thank you Stuart.

    But the documents my applications load have varying names, therefore would be a long search to determine if application loaded or document loaded. I shall have a go but will end up wasting alot of time searching the database for the given document name.

    There is no flag to say open in new instance?

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Opening documents in new instance of word (97)

    > will end up wasting alot of time searching the database
    Can you note the document name when you open it, and store an array of "documents I have opened this session"?

    > There is no flag to say open in new instance?
    I don't think so.

    StuartR

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Opening documents in new instance of word (97)

    In theory, whether Windows looks around for an open instance of an application or opens a new instance when you double-click a document is governing by registry settings. These are accessible for editing through the File Types tab of the Folder Options dialog in Windows Explorer. However, these settings don't always work as expected, and any changes you make will be global, meaning that Word will always open new instances for each document even when your application is not running. Still, it might be worth experimenting with the settings if no other solution is found.

    Addendum: I tested various things in Word 2000/Windows 2000 and couldn't get a new instance of the application to open when I double-clicked a .DOC in Windows Explorer. Word 97 might work better. We can hope!

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Opening documents in new instance of word (97)

    Take a look at the following property to see if it is available in Word 97:

    aDocument.UserControl

    In theory, a document you create under code control will return False, while a document launched by the user will return true. You could, in theory, have a global AutoOpen macro that would check this property and if True, check the state of the toolbars or whether your application is open/running. If the AutoOpen macro determines that the document needs to be closed and re-opened in a new instance of Word, you could then code that.

    Lots of assumptions and speculation here, but hope it helps.

  7. #7
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening documents in new instance of word (97)

    Jefferson, I don't think .UserControl will help in this case.

    For W2K's help file"

    "If Word is visible to the user, or if you call the UserControl property of a Word Application or Document object from within a Word code module, this property will always return True."

    So, if a Word instance is visible, then .UserControl will return True always.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Opening documents in new instance of word (97)

    I must have had one eye closed while reading. Oh well...

  9. #9
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Opening documents in new instance of word (97)

    Cindy,

    Will the documents that are opened by users outside of your application, have a different attached template than the documents created within your applicaton?
    If that is the case, then on Open you wouldn't need to filter by document name, you could determine ActiveDocument.AttachedTemplate and branch accordingly.

    Gary

  10. #10
    Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening documents in new instance of word (97)

    I thinking of trying to change the registry settings through code, as I do this alot from within Visual Basic, but am unsure which registry setting. Looking at an earlier post, can not remember which specific one, they stated that by changing the View, Options menu item in windows explorer, for File Types, Microsoft Word Document to open a new instance, a new instance of word will always open. If I could find how to do this I could maybe find the registry setting, though I am unable to find how to do this.

    Maybe I am just wasting time and should go with the document open option and set the menu items.

    Thanks for everyones help.

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Opening documents in new instance of word (97)

    I'd think twice before modifying the registry. As far as I can tell, the behavior on double clicking a Word 97 document is not governed by one single registry setting, but by a series of settings under HKEY_CLASSES_ROOTWord.Document.8ShellOpen.
    1. Changing this wouldn't work if somebody happens to use Word 2000 or XP.
    2. If Word hangs (it happens, you know), the code to restore the original settings won't get executed, and the user is left with undesirable settings.

  12. #12
    Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening documents in new instance of word (97)

    Stuart I am still grasping at straws here, but the code for document change is put in the document window, I do not have the capability of adding this code to all documents opened, please explain how I would, from my code template, capture a document change event?

    Sorry if this is basic

  13. #13
    Star Lounger
    Join Date
    Mar 2001
    Location
    Cheltenham, Pennsylvania, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening documents in new instance of word (97)

    Cindy:

    I found that I could, in fact, open another instance of Word. The prompts produced by the subroutine explain the minor problem this produces, though.

    (To put the routine into context, the program automates the creation of a resume and this subroutine allows the user to open an existing Word document to use as the source of material to copy/paste into the new resume. Because the calling program is modal, it was necessary to open a second instance of Word.)

    Hope this helps.

    Public Sub OpenAltSource()
    Dim strAltSource As String
    Dim dlgReturn As Dialog
    Dim appWD As Word.Application
    Dim strMessage As String
    strProc = "OpenAltSource"
    strMessage = "Another instance of Word will open in the background. Use it to open your external data source. You can leave it open while working with the resume." & vbCrLf & vbCrLf
    strMessage = strMessage & "Press Alt+Tab to switch to the alternate Word window, or choose it on your Windows toolbar." & vbCrLf & vbCrLf
    strMessage = strMessage & "To copy and paste information from another document, switch between the resume and the alternate source window." & vbCrLf & vbCrLf
    strMessage = strMessage & "After closing this message box the resume tool will appear. PRESS ALT+TAB to use the alternate Word window."
    MsgBox prompt:=strMessage, buttons:=vbOKOnly, Title:="Use External Data Source"

    Set appWD = CreateObject("Word.Application")
    appWD.Visible = True
    Set appWD = Nothing
    End Sub

  14. #14
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Opening documents in new instance of word (97)

    The example code in <post#=203498>post 203498</post#> shows you how to use the DocumentChange event.
    You should put this code in a Global template, in your Word Startup folder, so that it is available whatever document is open.

    StuartR

  15. #15
    Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening documents in new instance of word (97)

    This code will not work though. If the user then closes my application the second instance of word will be closed, therefore losing any changes made to the document. Also Word has a known fault, correct me if I'm wrong, that you can not open instances of word via code and then the user close them, when you start the next instance it will fail.

    I hope you understand what I am trying to say

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •