×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

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

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

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close