Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro which run a submacro in all drawings I have in a specific folder

Status
Not open for further replies.

JrJBS

New member
Dec 12, 2017
5
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
 
Replies continue below

Recommended for you

Hi,
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
 
Hello, thanks for the replies!

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor