Exporting to Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

As well as specifying the file name is it possible to specify the sheet as
well?
 
Here is the code how to mention the sheet name while transfering data to Excel.

Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet

Dim rst As Recordset

Dim iRow As Integer

'--- open the workbook
Set objXL = New Excel.Application
objXL.Visible = True
Set objWkb = objXL.Workbooks.Open("D:\MyProjects\MaterialList.xls")

'Here to mention the sheet name
Set objSht = objWkb.Worksheets("Sheet1")

' Further code lines..

Hope this helps

Ashfaque
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top