o1-preview-2024-09-12· openai
from WildChat-4.8M
To create a VBA script that opens each AI file in a specified directory and its…
Private research annotation
Sign in to add a private research label or note.
- User
To create a VBA script that opens each AI file in a specified directory and its subdirectories, and then applies the
DuplicateAndOutlineTextFramessubroutine, you can use the following code:vbaSub ProcessAIFilesInDirectory() Dim folderPath As String Dim fileName As String Dim filePath As String ' Set the folder path folderPath = "H:\1403\07\Final Labels Of Tanin Malihe\" ' Process all AI files in the folder and subfolders fileName = Dir(folderPath & "*.ai", vbNormal) Do While fileName <> "" filePath = folderPath & fileName OpenAndProcessAIFile filePath fileName = Dir Loop ' Process subdirectories ProcessSubdirectories folderPath End Sub Sub ProcessSubdirectories(ByVal folderPath As String) Dim subfolder As String Dim folder As Object Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") Set folder = fso.GetFolder(folderPath) ' Loop through each subfolder For Each subfolder In folder.SubFolders ProcessAIFilesInDirectory subfolder.Path Next subfolder End Sub Sub OpenAndProcessAIFile(ByVal filePath As String) Dim app As Object, doc As Object ' Create Illustrator Application Object Set app = CreateObject("Illustrator.Application") ' Open the document Set doc = app.Open(filePath) ' Call the procedure to duplicate and outline text frames DuplicateAndOutlineTextFrames doc ' Close the document doc.Close End Sub Sub DuplicateAndOutlineTextFrames(doc As Object) Dim txtFrame As Object, dupTxtFrame As Object ' Loop through text frames For Each txtFrame In doc.TextFrames ' Duplicate and create outlines Set dupTxtFrame = txtFrame.Duplicate dupTxtFrame.CreateOutline txtFrame.Visible = False Next txtFrame ' Save the document doc.Save Debug.Print "Process completed for: " & doc.Name End Sub - Assistant