Hi, Thanks for your response.
What I want to do is:
1. Fill in 3 fields (content controls) on the document i.e. Name, Date (DateTimePicker) and Subject.
2. When the user Selects/Clicks on Save/Save As, the dialog box needs to display and
i) All the content in the 3 fields needs to be combined and displayed in the "File Name" field of the dlgbox
ii) The dlgbox needs to open from a specified path.
Below is my code. But for some reason, one minute it works and the next it doesn't. Please have a look and let me know what I'm doing wrong.
Code:
Sub FileSave()
'
' FileSave Macro
' Saves the active document or template
'
Dim strName As String, strDate As String, strSubject As String
Dim strDocName As String
Dim dlgSaveAs As FileDialog
Dim ccCtrl As ContentControl
On Error GoTo errhandler:
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
With ActiveDocument
strName = .ContentControls("1017512746").Range.Text
strDate = .ContentControls("2985804456").Range.Text
strSubject = .ContentControls("821630576").Range.Text
End With
strDocName = strName & "_" & strDate & "_" & strSubject
With dlgSaveAs
If .Show = -1 Then
.InitialFileName = "C:\" & strDocName
.Title = strDocName
ActiveDocument.SaveAs2 (strDocName)
Else
MsgBox ("Document not saved!")
End If
End With
errhandler:
'MsgBox ("Error saving the document!")
End Sub