How Can I port Access table into Excel programatically ?

G

Guest

Hi

I have a MSAccess form in which on the click of a button I wish to export
certain fields in a subform into MSExcel. How do I proceed with that ? I have
this code automatically built up. but what all should I add to export
certain fields of data into excel sheet and view excel sheet.

Private Sub Command92_Click()
On Error GoTo Err_Command92_Click

Dim oApp As Object

Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
'Only XL 97 supports UserControl Property
On Error Resume Next
oApp.UserControl = True

Exit_Command92_Click:
Exit Sub

Err_Command92_Click:
MsgBox Err.Description
Resume Exit_Command92_Click

End Sub


Thanks in advance
Madhuri
 
G

Guest

While I have only used this for an Excel Import, and don't know all of the
parameters, I would start with something similar to this:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97...

Good Luck.

Sharkbyte
 
G

Guest

hi Sharkbyte,

I am trying to do thisin the MSaccess form coding
I added a button to run Excel application and the code for the button looks
like this
Private Sub Command93_Click()
On Error GoTo Err_Command93_Click
DoCmd.TransferSpreadsheet(acExport, acSpreadsheetTypeExcel9,
qKPWC_RECOUP, "C:\TRY", YES)

Exit_Command93_Click:
Exit Sub

Err_Command93_Click:
MsgBox Err.Description
Resume Exit_Command93_Click

End Sub

but the code dosent run and is giving me an error

1) It gives me a error that "=" is expected somewhere. Does the
transferdatasheet action return any value. If it does what datatype does it
return

I tried modifying and added a
Dim x as variant
and assigned
x = DoCmd.TransferSpreadsheet(acExport, acSpreadsheetTypeExcel9,
qKPWC_RECOUP, "C:\TRY", YES)

but now while executing the code it gives me

Compile error : highlighted on Transferspreadsheet method
"Expected function or variable"

Please help

Madhuri
 

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

Top