Word 2003 macro

James22

New Member
Joined
Oct 7, 2009
Messages
25
Im trying to create a macro which opens a dialog box with a specific path that I specify. The path has templates (.dot) in it which a user will open.

For example:

Sub FileOpen()

ChangeFileOpenDirectory "C:\Templates"
Dialogs(wdDialogFileOpen).Show

End Sub

However, if a user opens a template using the above macro, it 'opens' the template itself and not a new instance of it.

I have also tried:

Sub FileOpen()

ChangeFileOpenDirectory "C:\Templates"
Dialogs(wdDialogFileNew).Show

End Sub

which would open a new instance of the template but I am not able to specify a path on the network using this method. In Word 2003, when you do a File - New, in the right hand task pane you get an option "New from exisiting document". I would like to be able to use this button but then be able to specify a specific path for it to open. Does any one know if this is possible?

Any help will be much appreciated.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
What about creating a userform in Word, having a Combobox to list all the templates and add a button and then create a new document based on the select item or name from a drop down.
 
Upvote 0
This could be an option but we have over 200 templates on the network which are grouped into different sub sections. e.g

C:\Templates :- 9 Templates
C:\Templates\Letter :- 22 Templates
C:\Templates\Client :- 17 Templates
C:\Templates\Invoice :- 13 Templates

My thinking was that if I create one macro for each sub section which opens that folder on the network, then all the user would need to do is select the template they need.

This would also be the easiest way to maintain centrally as we can add and remove templates from the central folder without having to change the code in the macro each time.
 
Upvote 0
Within the form you could use several combo box options based on your subfolders and get VBA to fill the combo with the template names, so if you add more they will be easily found.

Then use a command button to open the selected one, or possibly use a listbox to show all of the templates and use an option button against the subfolder (category names).

The following code will get you started.

Sub ListDocNamesInFolder()
Dim sMyDir As String
Dim sDocName As String
' The path to obtain files.
sMyDir = "C:\My Documents\"
sDocName = Dir(sMyDir & "*.DOT")
' Add new document.
Documents.Add
' Insert folder name and file names in document.
Selection.TypeText "Documents in folder " & sMyDir & vbCr & vbCr
While sDocName <> ""
' Insert filename in document.
Selection.TypeText sDocName & vbCr
' Get next file name.
sDocName = Dir()
Wend
End Sub

This will list all the templates into a new word document
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,840
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top