Export Subform to Excel and open

C

Chad

I have a Subform on the main form that I can export to Excel, but I
would like for that data to open after the output command. behind the
click properties, I have:

Private Sub exportexcel_Click()
DoCmd.OutputTo acOutputForm, "frm_subform", acFormatXLS, _
strPath & "C:\\ServerData.xls" ', AutoStart:=-1

OpenExcelFile ("C:\\ServerData.xls")
Dim objXL As Object

On Error Resume Next

Set objXL = GetObject(, "Excel.Application")
Set objXL = GetObject(strPathToFile)

objXL.Application.Visible = True
objXL.Parent.Windows(1).Visible = True
End Sub

I am getting a "sub or function not defined" error.

Thanks in advance!
 
C

Chad

I have a Subform on the main form that I can export to Excel, but I
would like for that data to open after the output command.  behind the
click properties, I have:

Private Sub exportexcel_Click()
DoCmd.OutputTo acOutputForm, "frm_subform", acFormatXLS, _
strPath & "C:\\ServerData.xls" ', AutoStart:=-1

OpenExcelFile ("C:\\ServerData.xls")
Dim objXL As Object

On Error Resume Next

Set objXL = GetObject(, "Excel.Application")
Set objXL = GetObject(strPathToFile)

objXL.Application.Visible = True
objXL.Parent.Windows(1).Visible = True
End Sub

I am getting a "sub or function not defined" error.

Thanks in advance!

Nevermind... I had an error in the code, and was code-heavy. This is
simply the code:

Private Sub exportexcel_Click()
DoCmd.OutputTo acOutputForm, "frm_subform", acFormatXLS, _
strPath & "C:\\ServerData.xls" , True

This will save the file to your local machine, and open the results
up.

Thanks.
 

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