Hi all,
Have limited VBA capability and have gleaned the following code from various sources and it sorta works.
I am trying to have the fileSaveAs dialog forced to save to the users desktop, iow the default path showing up should point to the user's desktop instead of the last foldr used to open the document in question.
The doc is a Word doc with tables and formfield, protected and when opened the Document_Open event calls this macro with an "If" statement on Filename and I want to force a SaveAs upon opening the document but now the user has to navigate to a location of his choice or save in the default path's location which is not good.
How do I get the SaveAsDialog to show the path I have in strDocPath?
Also how can I disable the "Cancel" button on the SaveAs dialog?
Code follows:
TIA
Have limited VBA capability and have gleaned the following code from various sources and it sorta works.
I am trying to have the fileSaveAs dialog forced to save to the users desktop, iow the default path showing up should point to the user's desktop instead of the last foldr used to open the document in question.
The doc is a Word doc with tables and formfield, protected and when opened the Document_Open event calls this macro with an "If" statement on Filename and I want to force a SaveAs upon opening the document but now the user has to navigate to a location of his choice or save in the default path's location which is not good.
How do I get the SaveAsDialog to show the path I have in strDocPath?
Also how can I disable the "Cancel" button on the SaveAs dialog?
Code follows:
Code:
Sub ShowSaveAsDialog()
Dim objWSH
Dim uName As String 'holds the users login name
Set objWSH = CreateObject("WScript.Network")
uName = objWSH.UserName 'get the user's name
strDocPath = "C:\Documents and Settings\" & uName & "\Desktop\" 'to make path
strDocName = "MyNewCN.doc"
Dim dlgSaveAs As Dialog
Set dlgSaveAs = Dialogs(wdDialogFileSaveAs)
dlgSaveAs.Show 'Dialog with default NOT specified path
ActiveDocument.SaveAs FileName:=strDocPath & strDocName 'This saves doc in background
Set objWSH = Nothing
End Sub