Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Help with SaveAs script!!!!!!!

Status
Not open for further replies.

mnash60

Materials
Joined
Feb 21, 2012
Messages
29
Location
US
I have a SaveAs script that works. But Im having a hard time figuring out how to get it to loop through all the catia files to a folder?


Sub CATMain()

'Retrive the active document

Dim Doc As document
Set Doc = CATIA.Activedocument



Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select a folder:", NO_OPTIONS, "C:\Scripts")

Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path

MsgBox objPath

Set objFolderItem = CreateObject("Scripting.FileSystemObject")

Dim ShortPartNo, strFolderPath
ShortPartNo = Left(Doc.Name, 8)
MsgBox ShortPartNo
strFolderPath = objPath &"\"& ShortPartNo & "\"
MsgBox strFolderPath
If Not objFolderItem.FolderExists(strFolderPath) Then
objFolderItem.CreateFolder(strFolderPath)
End If

Doc.ExportData strFolderPath & ShortPartNo& ".stp", "stp"

End Sub
 
if your script for for the activedocument, then you can bring it into a for each loop like:

Code:
for each doc in catia.documents

[indent][i]check TypeName(doc) before you do anything here
your code[...][/i][/indent]


next doc

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top