

See a complete list of VB constants here. vbTab is used to indent while vbLf is used to go to the next line. The Close method closes the file when we’re finished writing. The CreateTextFile method then creates the TXT file and the WriteLine method allows us to write anything we want in the newly created TXT file.
#Catia v5 macro download code
In my code shown above, the CreateObject function returns the FileSystemObject (fs). PoLogStream.Write ("Product: " & oInProduct.Name & " (" & oInstances.Count & " comps)" & vbCrLf) PoLogStream.WriteLine ("- Walking down the Product Tree -" & vbLf) Set poLogStream = poFileSys.CreateTextFile("C:\Users\DatatoFile.txt", True) Set poFileSys = CreateObject("Scripting.FileSystemObject") Public poFileSys As Scripting.FileSystemObject PoLogStream.Write ( "Product: " & oInProduct.Name & " (" & oInstances.Count & " comps)" & vbCrLf) PoLogStream.WriteLine ( "- Walking down the Product Tree -" & vbLf) Set poLogStream = poFileSys.CreateTextFile( "C:\Users\DatatoFile.txt", True) '- Create logfile Set poFileSys = CreateObject( "Scripting.FileSystemObject") Public poLogStream As Scripting.TextStream 'Macro to Export CATIA Data to TXT File Public poFileSys As Scripting.FileSystemObject The following code illustrates how we can use the FileSystemObject to return a TextStream object that can be read from or written to: txt file at any point during your program. The second option to export to TXT is a bit more dynamic as it allows you to write information to the. PartName = Inputbox ("Please enter the file name.")

ProductDocument1.ExportData oLocation & partName & "." & _ĮxportFormat, "txt" End If End If End SubĮxportFormat = Inputbox ("Please choose format to export the tree as._ Type either 'xls' or 'txt'") 'Input box to enter file location Dim oLocation As String PartName = Inputbox ( "Please enter the file name.") Program cancelled please retry macro." Else 'Input box to enter name of file Dim partName As String IF exportFormat "xls" THEN IF exportFormat "txt" THEN

'Input box to select txt or xls Dim exportFormat As StringĮxportFormat = Inputbox ( "Please choose format to export the tree as._ Type either 'xls' or 'txt'") Set productDocument1 = CATIA.ActiveDocument
