Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Mar 2005
    Location
    Kent, England
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hiding document on load (VBA/Word 2007)

    Can anyone help ... please?

    Over the last few months I have moved previously created templates from VBA to VSTO and have noted that if a user creates a document based on a VSTO template and sends to another user via Outlook the VSTO template does not open as expected, due to the fact that the temporary location is not trusted (honestly this is not a VSTO question).

    The solution I have been given by Microsoft is to open the document from Outlook, copy to a new location and close - this is run programmatically and stored in Normal.dotm. The issue I have is that the document appears on the screen, closes and appears again, which can cause confusion for the user. To resolve this I would like to hide the first document opening, so that the user only sees one document open. I have looked at Application.ScreenUpdating = false but the first document still does appear to visibly open. I have also looked at Application.Visible = false but realised that if the application is already open this will confuse the user.

    My question is, is there a way to hide the first document from appearing on the screen?

    Many thanks
    Jack

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

    Re: Hiding document on load (VBA/Word 2007)

    How about

    <code>Documents.Open Filename:="whatever", Visible:=False</code>

    StuartR

  3. #3
    2 Star Lounger
    Join Date
    Mar 2005
    Location
    Kent, England
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding document on load (VBA/Word 2007)

    Hi Stuart

    Microsoft have provided the code which they have placed under AutoOpen - if I step through the code the document opens as "Read Only" before the code actually starts to run. Application.ScreenUpdating = False seems to work to some extent as the document does not fully appear on the screen but visually you can see that something is happening as there are three white boxes appear on the screen before the actual document opens.

    Regards
    Jack

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

    Re: Hiding document on load (VBA/Word 2007)

    Jack,

    I don't understand your reply. Did you specify Visible:=False when you opened the document? Did the document still appear on the screen?

    StuartR

  5. #5
    2 Star Lounger
    Join Date
    Mar 2005
    Location
    Kent, England
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding document on load (VBA/Word 2007)

    Sorry Stuart

    In Outlook, if I open the email then double click the attachment, AutoOpen runs (which is stored in Normal.dotm). If I place a breakpoint at the very first line of the code and step into it the document has already opened as "Read Only", so therefore cannot set the document as Visible = False. The Application.ScreenUpdating = False does hide the document to some extent but not completely - as the ScreenUpdating kicks in the screen flashes and three white boxes appear then disappear.

    Regards
    Jack

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

    Re: Hiding document on load (VBA/Word 2007)

    Jack,

    Sorry, I had assumed you were opening the document from VBA, if this is being opened by a double click from Outlook then I don't think there is much you can do.

    StuartR

    Edited to add.

    You could try starting the AutoOpen with doc.Visible = False, it might make the flicker a bit shorter.

Posting Permissions

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