View Single Post
 
Old 11-16-2014, 04:09 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Your syntax is incorrect. You need something like the following. The folder C:\mydocuments must exist!

Code:
Dim strName As String
Dim strNum As String
Dim oCC As ContentControl
Const strPath As String = "C:\mydocuments\" 'Which must exist!
        With ActiveDocument
        For Each oCC In .ContentControls
            If LCase(oCC.Title) = "tbpanelnumber" Then
                If Trim(oCC.Range.Text) = oCC.PlaceholderText Then
                    oCC.Range.Select
                    MsgBox "Enter TB Panel Number"
                    Exit Sub
                Else
                    strNum = Trim(oCC.Range.Text)
                End If
            End If
            If LCase(oCC.Title) = "tbpanelname" Then
                If Trim(oCC.Range.Text) = oCC.PlaceholderText Then
                    oCC.Range.Select
                    MsgBox "Enter TB Panel Name"
                    Exit Sub
                Else
                    strName = Trim(oCC.Range.Text)
                End If
            End If
        Next oCC
        .SaveAs2 Filename:=strPath & strNum & strName & ".docx"
    End With
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote