Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using OLE to Save an Excel Workbook(sheet) as different type

Status
Not open for further replies.

APS

Vendor
Sep 25, 2000
53
0
0
US
Hi
1. I have the code below which works except that it keeps saving the entire workbook and not just the sheet Totals99 as Totals. Can anyone tell me why?

2. If I wanted to save the sheet Totals99 as a tab delimited, DBF, or any other data type how would I change my saveas statement?

oexcel=createobject('excel.application')
oexcel.Workbooks.open('c:\bakesale\bakesl2000.xls')
oexcel.Sheets("Totals99").Select
oexcel.visible=.T.
oexcel.ActiveSheet.saveas("c:\bakesale\files\Totals.xls")
oExcel.quit
release oExcel

Thanks for the help!!!
Anthony
 
oexcel.ActiveSheet.SaveAs("c:\bakesale\files\Totals.XXX",xlFileFormat)

Set the extension appropriately and replace xlFileFormat with the following code:

DBase4 = 11
Dbase3 = 8
Dbase2 = 7

I'm not quite sure on the tab-delimited, you might try 20.

Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,

When All We Want Is Unity. - Creed
 
Thanks for the help Jon!

If 20 does not work, how can I found out what the code is?

Thanks again,
Anthony
 
Hi Anthony,

I use the VB Object Browser to view the Excel Object library.

I gave a brief intro to the VB OB in this thread: thread184-28224

I belive jfherring knows the name of the .h file that houses the constants definitions. Contact him.

Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,

When All We Want Is Unity. - Creed
 
For Excel2000, use -4158 for a tab delimited text file.

**oExcel.ActiveSheet.SaveAs("C:\myfile.txt", -4158)

one way to figure out what the constants are is to record a macro in Excel, do what you want to do, then look at the macro in the VBA editor. If you step into it ('f8'), when you hover the mouse cursor over the constant name, it will tell you what the value actually is. Does that sound as confusing to you as it does to me?

Also, if you send me an email (john.herring@carecall.com), I will reply to it with a .h file that includes some common Excel constans.
jfherring
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top