Open Excel from access

  • Thread starter Thread starter John
  • Start date Start date
J

John

I have not been able to figure out how to open a specific
excel workbook from access and have it be the active
screen. If anyone has any ideas I would greatly
appreciate it.

Thanks,
John
 
Try this in Access

Sub test()
On Error Resume Next
Set xl = GetObject(, "Excel.Application")
If xl Is Nothing Then
Set xl = GetObject("", "Excel.Application")
xl.workbooks.Open "C:\Data\book1.xls"
xl.UserControl = True
xl.Visible = True
End If
AppActivate "Microsoft Excel"
End Sub
 
Dear Ron,

The code did not work, it did not understand this part of
the code: AppActivate "Microsoft Excel"

If you have any other suggestions that would be great.

Thanks again,
John
 
Try it with the version number in the code like this

10 =2002
9=2000

Sub test()
On Error Resume Next
Set xl = GetObject(, "Excel.Application.10")
If xl Is Nothing Then
Set xl = GetObject("", "Excel.Application.10")
xl.workbooks.Open "C:\Data\book1.xls"
xl.UserControl = True
xl.Visible = True
End If
AppActivate "Microsoft Excel"
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)




John said:
Dear Ron,

The code did not work, it did not understand this part of
the code: AppActivate "Microsoft Excel"

If you have any other suggestions that would be great.

Thanks again,
John
 
See this page also
http://www.erlandsendata.no/english/index.php?t=envbaole

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)




Ron de Bruin said:
Try it with the version number in the code like this

10 =2002
9=2000

Sub test()
On Error Resume Next
Set xl = GetObject(, "Excel.Application.10")
If xl Is Nothing Then
Set xl = GetObject("", "Excel.Application.10")
xl.workbooks.Open "C:\Data\book1.xls"
xl.UserControl = True
xl.Visible = True
End If
AppActivate "Microsoft Excel"
End Sub
 
Back
Top