Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel object - save as csv from Word?
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel object - save as csv from Word?
Hi Tom
Thanks for that -- it works. However, it seems that when I use that syntax, if I save in any format other than an Excel format, I get a series of Excel save as dialogs (warnings that the file exists, the Excel dialog itself, then a warning about saving in a non Excel format) in addition to the Word dialog pointing out that a file of the same name already exists (I want to overwrite). Is there any way to avoid having all those Excel dialogs pop up? Chuck "Tom Ogilvy" wrote: 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel object - save as csv from Word?
On error resume next
Kill "C:\Myfile.csv On Error goto 0 objExcel..DisplayAlerts = False objExcel.ActiveWorkbook.SaveAs FileName:="c:\myfile.csv", Fileformat:=6"Chuck" objExcel.ActiveWorkbook.Close SaveChanges:=False objExcel.DisplayAlerts = True -- Regards, Tom Ogilvy wrote in message ... Hi Tom Thanks for that -- it works. However, it seems that when I use that syntax, if I save in any format other than an Excel format, I get a series of Excel save as dialogs (warnings that the file exists, the Excel dialog itself, then a warning about saving in a non Excel format) in addition to the Word dialog pointing out that a file of the same name already exists (I want to overwrite). Is there any way to avoid having all those Excel dialogs pop up? Chuck "Tom Ogilvy" wrote: 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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel object - save as csv from Word?
That's excellent, you're a star! ;) It's common sense really.
"Tom Ogilvy" wrote: On error resume next Kill "C:\Myfile.csv On Error goto 0 objExcel..DisplayAlerts = False objExcel.ActiveWorkbook.SaveAs FileName:="c:\myfile.csv", Fileformat:=6"Chuck" objExcel.ActiveWorkbook.Close SaveChanges:=False objExcel.DisplayAlerts = True -- Regards, Tom Ogilvy wrote in message ... Hi Tom Thanks for that -- it works. However, it seems that when I use that syntax, if I save in any format other than an Excel format, I get a series of Excel save as dialogs (warnings that the file exists, the Excel dialog itself, then a warning about saving in a non Excel format) in addition to the Word dialog pointing out that a file of the same name already exists (I want to overwrite). Is there any way to avoid having all those Excel dialogs pop up? Chuck "Tom Ogilvy" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
excel object linked to word will not add sums in word | Excel Discussion (Misc queries) | |||
PLS HELP! Excel imbedded object in Word | Excel Discussion (Misc queries) | |||
Print Word Object in Excel | Excel Discussion (Misc queries) | |||
TO MODIFY A EXCEL OBJECT FROM WORD USING VBA | Excel Programming | |||
Using vb to create an excel object and save it as a CSV file | Excel Programming |