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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save to Excel from sql

Status
Not open for further replies.

ym6905

Technical User
Dec 18, 2002
4
GT
Hi all,
anyone help, i have one agent to connect to sql via odbc, and the result save to my disk to a file xx.txt it's work , but i want to open excel and save the file as xls.

Thanks, for you helping.
 
Here's some code that opens excel, opens a template then adds data to a cell. Unless you need your information in a text file, I would skip that step and go directly to excel. If you use a text file you would have to do an import and indicate the separtors. By putting the information directly into excel, it is more direct and probably easier.

Code:
Set excelapp = createobject("excel.application")
excelapp.visible = True	
'excelapp.visible = False
excelapp.Workbooks.add("O:\Pretrialforms\MonthlyReferralReport")
Set exceldta = excelapp.Workbooks("MonthlyReferralReport1").Worksheets("Database")
Set excelsht = excelapp.Workbooks("MonthlyReferralReport1").Worksheets("MonthlyReferralReport")
excelapp.DisplayAlerts = False
exceldta.cells(1,1).value = doc.GetItemValue("AssignedTo")
Leslie
landrews@metrocourt.state.nm.us

There are 10 types of people in the world -
those who understand binary
and
those who don't!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top