Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 11-16-2014, 04:09 AM
gmayor's Avatar
gmayor gmayor is offline compile error in save code Windows 7 64bit compile error in save code Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,143
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
compile error in save code FileSystemObject Compile Error: User-Defined Type Not Defined gsrikanth Excel Programming 2 03-28-2022 06:32 AM
compile error in save code VBA code to compile one document based on multiple search terms Hoxton118 Word VBA 4 04-04-2021 06:02 AM
Compile error: sub or function not defined.. xena2305 Excel Programming 0 08-02-2011 10:17 AM
compile error in Word raco Word 0 09-28-2010 12:40 PM
Runtime error 5487 - Word cannot complete the save to to file permission error franferns Word 0 11-25-2009 05:35 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft