I'm trying to write a macro to add the same custom properties to every file in a folder, but whenever I try to insert a variable so I can define the folder in task scheduler, it throws an error. Everything I've looked up says that this is the right format, so I don't know what I'm doing wrong.
The part causing the error is "Const strFolderPath As String = \\\$\\\$\\\$FOLDER_PATH\\\$\\\$\\\$". It keeps saying "Compile Error: Invalid Character"
Option Explicit
Dim swApp As SolidWorks.Application
Dim swDoc As SolidWorks.Document
Dim prop As SolidWorks.CustomPropertyData
Dim fso As FileSystemObject
Dim fsoFile As File
Const strFolderPath As String = \\\$\\\$\\\$FOLDER_PATH\\\$\\\$\\\$
Dim fileCount As Long
Sub main()
Set swApp = CreateObject("SOLIDWORKS.Application")
Set fso = New FileSystemObject
fileCount = 0
' Loop through all files in the folder
For Each fsoFile In fso.FolderGetFiles(folderPath, "SLDPRT")
Set swDoc = swApp.Documents.Open(fsoFile.Path)
Set prop = swDoc.CustomPropertyData
' Example: Add or update a property
prop.SetProperty "PartNo", ""
prop.SetProperty "Description", ""
prop.SetProperty "DrawnBy", "AL"
prop.SetProperty "DrawnDate", ""
' Save the document
swDoc.Save
fileCount = fileCount + 1
Next fsoFile
MsgBox "Processed " & fileCount & " files."
End Sub 