Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / July 2005

Tip: Looking for answers? Try searching our database.

opening a specific spreadsheet in excel from an access form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ac512 - 28 Jul 2005 02:11 GMT
I am currently working in access, using a form, and I would like to create a
button which opens a specific spreadsheet in a specific excel workbook.  
Currently I am using the following code to open the workbook:
   Dim stAppName As String

   stAppName = "C:\Program Files\Microsoft Office\Office10\EXCEL.EXE
N:\SMDiv\Test\Reporting.xls\vehicle charts"
   Call shell(stAppName, 1)

Exit_Command189_Click:
   Exit Sub

Err_Command189_Click:
   MsgBox Err.Description
   Resume Exit_Command189_Click

End Sub
If there is a better way to do this, I would appreciate that as well
Thank you
Jon Ley - 28 Jul 2005 16:16 GMT
Add a reference to the Microsoft Excel 10.0 Object Library and then:

Dim appExcel As Excel.Application
Dim wbExcelFile as Excel.Workbook

Set appExcel = CreateObject("Excel.Application")
Set wbExcelFile = appExcel.Workbooks.Open("N:\SMDiv\Test\Reporting.xls")
wbExcelFile.Sheets("vehicle charts").Select

'Optionally do other stuff with the workbook, including perhaps save and
close.
'Similarly you can quit Excel if you want.
'Alternatively you can just leave them open for the user to work with.
'Whatever you do, don't forget to release the object variables when you've
finished with them ...

Set wbExcelFile = Nothing
Set appExcel = Nothing

> I am currently working in access, using a form, and I would like to create a
> button which opens a specific spreadsheet in a specific excel workbook.  
[quoted text clipped - 15 lines]
> If there is a better way to do this, I would appreciate that as well
> Thank you
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.