mnash60
Materials
- Feb 21, 2012
- 29
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
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