View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Excel object - save as csv from Word?

objExcel.ActiveWorkbook.SaveAs FileName:="c:\myfile.csv", Fileformat:=6

--
Regards,
Tom Ogilvy

"Chuck" wrote in message
...
From within a Word macro I'm trying to save an Excel object as a csv file,
but can't seem to find any documentation that explains how to do it. Any
ideas? Code below -- I've tried objExcel.dialogs(xlDialogSaveAs).show but
get an error saying that xlDialogSaveAs is an undefined variable, and when

I
try to specify xlCSV as a file format I get the same undefined variable

error:

sub SaveAsCSV()

Dim objExcel As Object

Set objExcel = CreateObject("Excel.Application")

objExcel.Workbooks.Add

[snip - doing stuff to workbook]

objExcel.ActiveWorkbook.SaveAs FileName:="c:\myfile.csv"
'The above line saves as an .xls even if the suffix is ".csv"

objExcel.Application.Quit

Set objExcel = Nothing

end sub