In Word, Programmatically Open New Document Dialog

I'm looking for a way to programmatically open the New Document dialog in Word 2007. This is the one you get when you choose File-> New. You can also open it with the FileNew macro or the "New ..." command. However, I haven't been able to find a way to do this programmatically.

I tried:

Application.Run MacroName:="FileNew"

      

and

Dialogs(wdDialogFileNew).Show

      

and

CommandBars.FindControl(ID:=5746).Execute

      

but they both open the old dialog, not the new one that Word 2007 uses.

+2


source to share


3 answers


If there is a "real" VBA command to open this dialog, I cannot find it. However, I found this extremely lame workaround with a quick search:

SendKeys "%"
SendKeys "F"
SendKeys "N"

      



He does what you want! Found it here http://www.eggheadcafe.com/software/aspnet/32228837/new-file-dialog-in-word-2.aspx

+2


source


Can you get the command id for a button and execute it?

Dim c As CommandBarControl
Set c = CommandBars.FindControl(ID:=18)
c.Execute

      



Control ID 18 is the Application ID for the New ... button.

+1


source


I think you can just use:

Documents.Add

      

without any parameters.

0


source







All Articles