mferrisi
05-20-2008, 01:16 PM
After making changes to a workbook, the following code brought up a Save As window and allowed the user choose the name and location of the saved document.
Function SaveDoc(wt, Name, IsOpen, TheDate)
If MsgBox("Would you like to save the tagged files for " & Name & "?", vbYesNo) = vbYes Then
With Application.FileDialog(msoFileDialogSaveAs)
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
wbFilename = .SelectedItems(1)
.InitialFileName = wbFilename
.Execute
Else: End If
End With
End Function
As now the program loops though to create multiple documents, I no longer want to have to type the saved name and find the folder. The 'wt' is the path where I want the file to be saved. I attempted to do it liek this:
If MsgBox("Would you like to save the tagged files for " & Name & "?", vbYesNo) = vbYes Then
With Application.FileDialog(msoFileDialogSaveAs)
.AllowMultiSelect = False
wbFilename = Left(wt, Len(wt) - 4) & "_Proc.xls"
.SelectedItems.Application = wbFilename
.InitialFileName = wbFilename
.Execute
End With
But this caused the file to save, but with the original name, ie I save over the original document, and _Proc.xls is not added to the name.
Thank you for your help,
Function SaveDoc(wt, Name, IsOpen, TheDate)
If MsgBox("Would you like to save the tagged files for " & Name & "?", vbYesNo) = vbYes Then
With Application.FileDialog(msoFileDialogSaveAs)
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
wbFilename = .SelectedItems(1)
.InitialFileName = wbFilename
.Execute
Else: End If
End With
End Function
As now the program loops though to create multiple documents, I no longer want to have to type the saved name and find the folder. The 'wt' is the path where I want the file to be saved. I attempted to do it liek this:
If MsgBox("Would you like to save the tagged files for " & Name & "?", vbYesNo) = vbYes Then
With Application.FileDialog(msoFileDialogSaveAs)
.AllowMultiSelect = False
wbFilename = Left(wt, Len(wt) - 4) & "_Proc.xls"
.SelectedItems.Application = wbFilename
.InitialFileName = wbFilename
.Execute
End With
But this caused the file to save, but with the original name, ie I save over the original document, and _Proc.xls is not added to the name.
Thank you for your help,