Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-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
Feb 21, 2012
29
0
0
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
 
Replies continue below

Recommended for you

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.
Back
Top