In Word 2003, the following code works like a charm:
If Dialogs(wdDialogFileNew).Show = -1 Then
‘some code here
End If
This shows the FileNew dialog where you can pick a template and, after clicking OK, a new doc is created based on that template.
I tried something similar in Excel:
If Application.Dialogs(xlDialogWorkbookNew).Show = -1 Then
‘some code here
End If
This doesn’t work as I expected.
First, it doesn’t create a new workbook based on the chosen template. It inserted an extra Sheet in the current workbook. And there was no sign of the custom commandbar that should be created and made visible. (The code to do that works fine in Excel97 for 2 years.)
Second, Excel insists that Application. should be in front of Dialogs(…). If not, it complains with:
Compile error: Sub or Function not defined
Third, if this code is called when there’s NO workbook already open, this error occurs:
Runtime error 1004: Property Show of class Dialog cannot be (found / loaded ?)
(in Dutch: Eigenschap Show van klasse Dialog kan niet worden opgehaald)
What am I doing wrong?