Opening Excel File After Creation

kipster1203

Registered User.
Local time
Today, 14:51
Joined
May 5, 2010
Messages
13
I am creating an excel file using the following commands (with lots of code before it)

DoCmd.TransferSpreadsheet acExport, , "First Pass Yield Chart Query", "W:\edsplus\applications\0cmad\cmad_chart_spreadsh eet.xls", True, "First_Pass_Yield_Data"

DoCmd.TransferSpreadsheet acExport, , "Average Temp Table", "W:\edsplus\applications\0cmad\cmad_chart_spreadsh eet.xls", True, "First_Pass_Yield_Sum_Average"

And this creates the excel file and puts it in the file location folder and it works fine but it doesn't open the file after it creates it. So I need to know how I can make it so that this file also gets opened.
 
How about this:

Code:
[B]Dim strFile As String
strFile = "W:\edsplus\applications\0cmad\cmad_chart_spreadsheet.xls"[/B]
DoCmd.TransferSpreadsheet acExport, , "First Pass Yield Chart Query",[B]strFile [/B], True, "First_Pass_Yield_Data"

[B]FollowHyperlink strFile[/B]

[B]strFile = "W:\edsplus\applications\0cmad\cmad_chart_spreadsheet.xls"[/B]

DoCmd.TransferSpreadsheet acExport, , "Average Temp Table",[B]strFile [/B], True, "First_Pass_Yield_Sum_Average"

[B]FollowHyperlink strFile[/B]

Or an alternative

Code:
[B]Dim strFile As String[/B]
[B]Dim objXL As Object
Dim objWB As Object[/B]

[B]strFile = "W:\edsplus\applications\0cmad\cmad_chart_spreadsheet.xls"[/B]

DoCmd.TransferSpreadsheet acExport, , "First Pass Yield Chart Query",[B]strFile [/B], True, "First_Pass_Yield_Data"

[B]Set objXL = CreateObject("Excel.Application")
objXL.Visible = True
Set objWB = objXL.Workbooks.Open(strFile)

objXL.UserControl = True
Set objXL = Nothing[/B]


[B]strFile = "W:\edsplus\applications\0cmad\cmad_chart_spreadsheet.xls"[/B]

DoCmd.TransferSpreadsheet acExport, , "Average Temp Table",[B]strFile [/B], True, "First_Pass_Yield_Sum_Average"

[B]Set objXL = CreateObject("Excel.Application")
objXL.Visible = True
Set objWB = objXL.Workbooks.Open(strFile)

objXL.UserControl = True
Set objXL = Nothing[/B]
 
Thanks Bob - the hyperlink method didn't work but the alternative works fine.
 

Users who are viewing this thread

Back
Top Bottom