I need some assistance with modifying an existing (working) macro.
Here's what I currently have:
- Word document saved as a template (.dot extension). The Word template is stored in folder anywhere (e.g., Desktop).
- Another folder on the C-drive… C:\MyFolderLocation.
The Word template contains the following fields/command buttons:
- 3 fields where user enters information (e.g., [Date], [Name], [Description]).
- 1 command button "Copy Me!"
Below is the process (which again works great right now):
- User opens (double-clicks) on Word template
- Word opens... new file name is called "Document1"
- User then modifies information for [Date], [Name], and [Description]
- User then clicks on command button "Copy Me!"
- Now, file "Document1" changes its filename/extension to "MyFileName.doc"
- Then, file "MyFileName.doc" is automatically saved in C:\MyFolderLocation
Again, the above process works great... but now I need to slightly modify it. Here's what I need some help with.
The folder location (C:\MyFolderLocation) and filename (MyFileName.doc) are currently hard-coded in the VBA code (see bottom of this post).
Now, instead of using the hardcoded folder location and filename, I'd like the user to determine these themselves. Thus, the following is envisioned:
1. Just as before, the user opens the Word template (which contains the 3 required fields).
2. Again, the user adds information such as [Date], [Name], [Description]
3. Now, however, user types in a filename (somewhere where the VBA code can "recognize" it)
4. Also, user can select a folder location (via Browse dialog box).
5. Then, just before, the user click on command button "Copy Me!".
6. Now, the new file copy is stored wherever specified with the chosen filename.
Please keep in mind that we're NOT just opening a new (blank) Word document where the user can merely save it anywhere with any file name. The difference is that this template includes pre-defined fields (actual document has more than just 3 fields). Thus, I must use the template.
Please see attached current Word document/template. For testing purposes, create a folder "C:\MyFolderLocation" and then open the .dot. Whatever information you'll type into the 3 fields are then saved accordingly. Hopefully this helps facilitating the process.
Thank you in advance for helping me figuring out modifications (step #4 and #5).
Private Sub CommandButton1_Click()
Dim doc As Document
Set doc = ActiveDocument