![]() |
|
#1
|
|||
|
|||
![]()
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 |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
samanthab | Word | 3 | 01-19-2013 06:27 AM |
![]() |
jillapass | Word VBA | 7 | 03-30-2012 03:24 PM |
Keyboard Commands | korric | Word | 3 | 02-09-2012 12:52 AM |
![]() |
tinfanide | Excel Programming | 4 | 11-05-2011 01:40 AM |
Advance Commands | Richard1 | Word | 0 | 02-10-2011 01:35 PM |