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

Access - creating workbook (excel)

Status
Not open for further replies.

JoanaSantos

Programmer
Feb 24, 2015
33
EU
Hi, I have created this code to save the info of one table in excel :

but in the end i stay with two sheets: sheet1 and F01Incos01. Can u help me? i just want to stay with the sheet "F01Incos01"


Private Sub Command329_Click()

Dim newExcelApp As Excel.Application
Dim newWbk As Excel.Workbook
Dim newWkSheet As Excel.Worksheet

Set newExcelApp = Excel.Application
'Set newExcelApp.Visible = True

Set newWbk = newExcelApp.Workbooks.Add(xlWBATWorksheet)
'Set newWkSheet = newWbk.Worksheets(1)

newWbk.SaveAs "C:\Joana\F01Incos01.xlsx"
strExcelPath = "C:\Joana\F01Incos01.xlsx"

newWbk.Save
newWbk.Close

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"F01Incos01", strExcelPath, True

DoCmd.SetWarnings True

MsgBox "Processo Concluído!"

End Sub
 
I agree with 1DMF you do not need to create the Excel file first. Excel when it creates a workbook by default creates 1 or more new sheets.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top