Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Specific Excel File in Access Form

Status
Not open for further replies.

Cordury

Technical User
Jun 2, 2003
147
US
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.

Thanks,
Cord
 
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

Let me know how you get on.

Bill
 
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


Exit_cmdSiteMaintenance_Click:
Exit Sub

Err_cmdSiteMaintenance_Click:
MsgBox Err.Description
Resume Exit_cmdSiteMaintenance_Click

End Sub
 
Hi Cordury,

There is another way to do this. If you look at
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.

Bill
 
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.

Can you open the DB yourself.

Bill
 
Bill,

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.

I hope I answered your question.

Thanks again for all of you help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top