Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    853
    Thanks
    0
    Thanked 9 Times in 8 Posts

    Built-in Dlg (FileOpen) (Word 2007)

    I've written a macro to open a template from the Word 2007 Startup folder and unload it as well. (Unloading a global template before editing VBA is recommned in 2007, and I do find that it's the safe way to proceed.) A similar macro closes and reloads the template. (I've placed both macros on the Developer tab of the Ribbon.)

    I'm finding (with 100% consistency) that double-clicking the file in the FileOpen dialog does not cause .Execute to open the fiile. (The Open buttons functions as expected.) VBA "gets" the name of selected file; the template is unloaded as expected. Is this as intended? I've worked around it by getting the document count as the macro starts; if the count has not incremented by 1, I use Documents.Open to open sFileName. This works well enough, but I'm wondering if a double-click is no longer intended to be the equivalent of the default (Open) button.

    Dim sFileName as String
    ChangeFileOpenDirectory Options.DefaultFilePath(wdStartupPath)
    With Application.Dialogs(wdDialogFileOpen)
    .Display
    sFileName = .Name
    AddIns(sFileName).Installed = False
    .Execute
    End With

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

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

    Re: Built-in Dlg (FileOpen) (Word 2007)

    I don't have Word 2007, but according to Displaying Built-in Word Dialog Boxes [Word 2007 Developer Reference], the Execute method should work the same in Word 2007 as in previous versions. I can't find any mention that it doesn't work in the newsgroups. I hope that someone with Word 2007 can test this.

  4. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,779
    Thanks
    0
    Thanked 162 Times in 150 Posts

    Re: Built-in Dlg (FileOpen) (Word 2007)

    Hi Richard,

    I don't have any addins in my startup folder but, if I comment out the line 'AddIns(sFileName).Installed = False' and navigate to a folder where I have some documents and select a file, the .Execute statement seems to work (ie the file opens) with my copy of Word 2007.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #4
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    853
    Thanks
    0
    Thanked 9 Times in 8 Posts

    Re: Built-in Dlg (FileOpen) (Word 2007)

    Paul,

    Thanks for giving this a try. I have the problem only when I double-click the file; the Open button functions as expected. I had better luck with this:

    rc = .Display
    If rc = -1 then ' Open button (or double-click)
    .Execute
    End If

    That shouldn't be necessary, but it did trigger the execution I expected. I'll try this in another macro in another project to determine if this was just an anomaly.

    Richard

Posting Permissions

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