1

I am using Microsoft Visual Basic for Application. Here I want to store my data into a .csv file.

Dim FileName As String
Dim PathName As String
Dim ws As Worksheet

Set ws = ActiveWorkbook.Sheets("Sheet1")
FileName = "filename.csv"
PathName = Application.ActiveWorkbook.Path
ws.Copy
ActiveWorkbook.SaveAs FileName:=PathName & "\" & FileName, _
    FileFormat:=xlCSV, CreateBackup:=False

By using the code we can convert the data to .csv file.

Error:Method 'Sheets' of object '_Global' failed

This is the error because there is no worksheets are active. But when I use this macros in Excel it will work. But I'm using it in Microsoft Visual Basic for Applications in CATIA. So I don't wanna introduce Excel variable here. It cause some compatibility issue. So please help me to create a csv file in VBA? Thanks in Advance.

Community
  • 1
  • 1
Moni
  • 47
  • 2
  • 11

1 Answers1

0

Look on this site: http://www.coe.org/p/fo/et/thread=27438

There is a macro to export the settings from CATIA and they say there is a built-in option to export some settings.

If you need to create a csv file for any other reason, you should be able to extact the line of code from the macro thats posted there.

Plagon
  • 2,689
  • 1
  • 11
  • 23