I know it is possible to add a command button to open another Microsoft application on a form. It is possible to have the app open a specific file? I would like to add a button that opens up an Excel Template.
This will open a specific workbook:
Dim xlobj As Object, strExcelFile As String
strExcelFile = "c:\my documents\Data.xls"
Set xlobj = CreateObject("excel.application"
xlobj.Application.Visible = True
With xlobj
.Workbooks.Open FileName:=strExcelFile
.Worksheets("Sheet1".Select
End With
Set xlobj = Nothing
If you don't need to specify a sheet, delete the line:
.Worksheets("Sheet1".Select
Thanks Bill- I should just create a command button and enter the code you provided with the specified path of the desired file?
Something like:
Private Sub cmdSiteMaintenance_Click()
On Error GoTo SiteMaintenance_Click
Dim xlobj As Object, strExcelFile As String
strExcelFile = "S:\ENERGY\UTILITY\Utility Logs\Site Maintenance\2003\Template.xls"
Set xlobj = CreateObject("excel.application"
xlobj.Application.Visible = True
With xlobj
.Workbooks.Open FileName:=strExcelFile
'.Worksheets("Sheet1".Select
End With
Set xlobj = Nothing
I have and example called CommonDialogAccess97.zip or CommonDialogAccess2000.zip
[/color]
If you select Print or Open Selected File from the Switchboard, will open the selected file.
Thank you both for your prompt resposnes. This afternoon I am going to try your recommendations and see what I come up with.
I do have another issue (maybe you can help me out with):
I have somehow loxked down my db so no one else can use it. When another person tries to open it, they get a message box saying that the db "has been placed in a state by me and can not be opened or edited".
I have no idea how I have done this nor how to disable it.
If the DB is on a shared drive and you have it open in design mode, this could cause the problem.
Really you need to do some explaining about your setup. Is your DB split, tables on a shared drive, Program on local drives. Usually referred to Front End and Back End.
My db is on a shared drive and I can open it in any view with no issue.
I added one of the user names under 'User Names and Accounts' and she can now view the database. I am not too comfortable with this option since I don't really understand it. I thought if I just changed the Startup option to open in form view no one would have an issue getting in. No one using the db is very Access savy so using the shift+enter function is safe enough for me and the databse.
All users have Access on their machines and all of the tables are on the shared drive.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.