Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Using vb to create an excel object and save it as a CSV file

I am using the following code from a VB app to create an excel object, populate some information and then save the excel file
Dim oExcel As Objec
Dim oBook As Objec
Dim oSheet As Objec
Set oExcel = CreateObject("Excel.Application"
Set oBook = oExcel.workbooks.Ad
Set oSheet = oBook.Worksheets(1
oSheet.Range("A1").Value = "EntryNumber
oSheet.Range("B1").Value = "CheckNumber
oSheet.Range("C1").Value = "CheckAmount
oSheet.Range("D1").Value = "InvoiceNumber
oSheet.Range("E1").Value = "invoicetype
oBook.Saveas rptpath & "\cashreceipts.xls
oExcel.qui
although not displayed here I am populating the worksheet with the results of an ADODB recordse
using the copyfromrecordset method
This works fine but I actually want to save the file in CSV format.
i saw the .fileformat property in excel but can't seem to get it to work properly.
Any suggestions on how to get my existing code to save the file as a csv would be greatly appreciated
Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Using vb to create an excel object and save it as a CSV file

eli;

Try the following sub. You will need to modify the path
and file name for yours.

Sub try()

ChDir "C:\Data"
ActiveWorkbook.SaveAs Filename:="C:\Data\Book1.csv",
FileFormat:=xlCSV, _
CreateBackup:=False
End Sub

Thanks

Greg



-----Original Message-----
I am using the following code from a VB app to create an

excel object, populate some information and then save the
excel file.
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.workbooks.Add
Set oSheet = oBook.Worksheets(1)
oSheet.Range("A1").Value = "EntryNumber"
oSheet.Range("B1").Value = "CheckNumber"
oSheet.Range("C1").Value = "CheckAmount"
oSheet.Range("D1").Value = "InvoiceNumber"
oSheet.Range("E1").Value = "invoicetype"
oBook.Saveas rptpath & "\cashreceipts.xls"
oExcel.quit
although not displayed here I am populating the worksheet

with the results of an ADODB recordset
using the copyfromrecordset method.
This works fine but I actually want to save the file in

CSV format.
i saw the .fileformat property in excel but can't seem to

get it to work properly.
Any suggestions on how to get my existing code to save

the file as a csv would be greatly appreciated.
Thanks in advance.
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CREATE TEMPORARY FILE WHEN SAVE Bhavin Excel Discussion (Misc queries) 0 October 2nd 09 02:01 PM
Excel changes file extension on embedded object upon save Brent-GPTX Excel Discussion (Misc queries) 1 April 24th 09 05:23 PM
In Excel, I want to create a backup copy whenever I save a file. Bearpecs Excel Discussion (Misc queries) 1 June 7th 06 01:52 PM
Excel 2000 cannot save and create temp file GK Setting up and Configuration of Excel 1 October 25th 05 10:33 PM
how do i create and save a new file or worksheet autmatically ever DAN Excel Discussion (Misc queries) 0 March 30th 05 03:07 PM


All times are GMT +1. The time now is 08:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"