bstephens
11-25-2009, 12:45 AM
I am trying to create a "SmartSave" macro whereby a user enters text into a "Text Form Field" and that text is appended to a static network path as the default save directory.
For example, say our standard client letter had a "Text Form Field" and an assistant manually typed a value of "72305.01" (that happens to be the client number) into the "Text Form Field" The macro would suggest a save directory of a static network path "J:\Docs\2009\" appended with "72305.01", so that the default save directory would be "J:\Docs\2009\72305.01".
I started with the following macro I found going through these forums, but I am stuck at the "'what goes here???" comment as to how to add the code which will "append" a static network path with a value from a "Text Form Field".
Also, if I am not using the "Text Form Field" field terminology correctly, I stand humbly corrected.
Sub FileSmartSave()
Dim aDialog As Dialog
Dim FileName As String
Dim CurrentSaveFolder As String
' pick up existing save folder
CurrentSaveFolder = Options _
.DefaultFilePath(Path:=wdDocumentsPath)
' the string for the filename
FileName = "your filename"
' change the FileOpen folder to desired folder
ChangeFileOpenDirectory 'what goes here???
' display FileSaveAs with your filename
' folder is the folder used with ChangeFileOpen
Set aDialog = Application.Dialogs(wdDialogFileSaveAs)
With aDialog
.Name = FileName
.Show
End With
' put the save folder path back
Options.DefaultFilePath(Path:=wdDocumentsPath) = _
CurrentSaveFolder
End Sub
Thanks in advance for any input!
Brian
For example, say our standard client letter had a "Text Form Field" and an assistant manually typed a value of "72305.01" (that happens to be the client number) into the "Text Form Field" The macro would suggest a save directory of a static network path "J:\Docs\2009\" appended with "72305.01", so that the default save directory would be "J:\Docs\2009\72305.01".
I started with the following macro I found going through these forums, but I am stuck at the "'what goes here???" comment as to how to add the code which will "append" a static network path with a value from a "Text Form Field".
Also, if I am not using the "Text Form Field" field terminology correctly, I stand humbly corrected.
Sub FileSmartSave()
Dim aDialog As Dialog
Dim FileName As String
Dim CurrentSaveFolder As String
' pick up existing save folder
CurrentSaveFolder = Options _
.DefaultFilePath(Path:=wdDocumentsPath)
' the string for the filename
FileName = "your filename"
' change the FileOpen folder to desired folder
ChangeFileOpenDirectory 'what goes here???
' display FileSaveAs with your filename
' folder is the folder used with ChangeFileOpen
Set aDialog = Application.Dialogs(wdDialogFileSaveAs)
With aDialog
.Name = FileName
.Show
End With
' put the save folder path back
Options.DefaultFilePath(Path:=wdDocumentsPath) = _
CurrentSaveFolder
End Sub
Thanks in advance for any input!
Brian