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

export to excel

Status
Not open for further replies.

santosh1

Programmer
Apr 26, 2002
201
US
Hello,

Using VB, I am trying to export MSAccess select query table to excel. This Select query table has 2 parameter fields, month and year, so while exporting this table, it asks for user input month and year. In the VB program, this 2 parameter is already known, how can I pass this 2 fields to the access query, so that it exports the table without asking for user input? I will appreciate your help very much. Thankyou.

Sub ExportToExcel()
Dim acApp As Access.Application
Dim exApp As Excel.Application

On Error GoTo errExportToExcel

Screen.MousePointer = vbHourglass

Set acApp = CreateObject("Access.Application")
acApp.Application.OpenCurrentDatabase "Placements.mdb"

acApp.DoCmd.TransferSpreadsheet acExport, 8, "Placements", "Placements.xls", True, ""

Set exApp = CreateObject("Excel.Application")
exApp.Workbooks.Open "Placements.xls"
exApp.Application.Visible = True
exApp.Application.ActiveWorkbook.Activate

Set acApp = Nothing
Set exApp = Nothing

Screen.MousePointer = vbDefault
Exit Sub
End Sub


Santosh
 
TRY IMPORTING FROM EXCEL IT'S CLEANER AND IT IS A LIVE LINK
WITH NO CODE TO WRITE.

FROM ANY SPREADSHEET...

DATA>GET EXTERNAL DATA>...CHOOSE MSACCESS DATABASE* FROM THE LIST THEN FOLLOW THE WIZARD OR///// USE MS_QUERY


YOU CAN SET PROPERIES OF THE DATA RETURNED (RIGHT CLICK IN THE DATA AREA) FOR UPDATE ON OPEN, ETC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top