Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    London, Gtr London, England
    Posts
    416
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pass parameter to Documents.Open (WORD 2000 & after)

    Hi

    Is it possible to pass 'user specific' parameter(s) to Documents.Open command? The reason I ask is that in one of the documents I display a userform on the screen when a document is opened (i.e. within Document_Open event). For specific instances - I would prefer it not to display the userform.

    Also, when I open this document (Document.Open FileName:=ABC.DOC, Visible:=False) - it still displays the userform! I basically would like to open the document in stealth mode. I tried using GetObject method but that refuses to open the document:

    Dim oWordDoc As Word.Document

    With Dialogs(wdDialogFileOpen) ' Select and open the file to convert
    .Name = "*.doc"
    If .Display = 0 Then ' if convert from file selection
    Exit Function ' cancelled - exit conversion process
    End If
    'Open the document with GetObject (so it's invisible)
    msgbox (.name) This displays the selected filename correctly
    Set oWordDoc = GetObject(.name)

    This fails with Automation error

    Thanks

    Robie
    Attached Images Attached Images
    Thanks.
    Robie

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

    Re: Pass parameter to Documents.Open (WORD 2000 & after)

    Insert this line before the code that opens the document:

    WordBasic.DisableAutoMacros 1

    To reenable automatic macros afterwards, use

    WordBasic.DisableAutoMacros 0

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

    Re: Pass parameter to Documents.Open (WORD 2000 & after)

    That works beautifully. How do you do it Hans? Fantastic. Thanks a bunch. <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>
    Thanks.
    Robie

Posting Permissions

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