Macro which run a submacro in all drawings I have in a specific folder
Macro which run a submacro in all drawings I have in a specific folder
(OP)
Hello all,
I'm trying to create a macro which run a sub macro in all drawings I have in a specific folder, opening all drawings I have, running the submacro and closing them with the following code:
For Each MyFile In MyFiles
If MyFile.Type = "CATIA Drawing" Then
MyFile.Open 'ERROR
Call SubMacro
MyFile.Close
End If
Next 'Myfile
I'm sure that the code to open a file isn't "MyFile.Open"
Some ideas?
Thanks
I'm trying to create a macro which run a sub macro in all drawings I have in a specific folder, opening all drawings I have, running the submacro and closing them with the following code:
For Each MyFile In MyFiles
If MyFile.Type = "CATIA Drawing" Then
MyFile.Open 'ERROR
Call SubMacro
MyFile.Close
End If
Next 'Myfile
I'm sure that the code to open a file isn't "MyFile.Open"
Some ideas?
Thanks





RE: Macro which run a submacro in all drawings I have in a specific folder
if all of drawings are opened in the CATIA, can you use number of opened windows
like first to get number of opened windows and then set for loop( i don't know can
you get this i didn't count them before, but i think you can.
For i=1 to number of opened windows
If MyFile.Type = "CATIA Drawing" Then
MyFile.Open 'ERROR
Call SubMacro
MyFile.Close
End If
next
RE: Macro which run a submacro in all drawings I have in a specific folder
Dim params()
CATIA.SystemService.ExecuteScript"path", catScriptLibraryTypeDirectory, "Macro2.catvbs", "CATMain", params
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Macro which run a submacro in all drawings I have in a specific folder
I fixed the problem with the following code:
For i = 1 To filefolder.Files.Count
Dim IFile
Set IFile = filefolder.Files.Item(i)
If InStr(IFile.Name, ".CATDrawing") <> 0 Then
Dim Doc
Set Doc = CATIA.Documents.Open(IFile.Path)
Set PartDocument1 = CATIA.ActiveDocument
Call Submacro
CATIA.ActiveDocument.Save
CATIA.ActiveDocument.Close
End If
End Sub