Open random excel spreadsheet from MS Access

jex57

Board Regular
Joined
Oct 29, 2015
Messages
62
Hi
Please can someone assist opening excel from access - but I do not want to specify the path,, so am looking for the open dialog box.

Also I have heard you need to close the instance of excel once the user has closed excel,
Please can someone let me know how it is done.

I have got the following code - but need the path to be a dialog box.

Thank you

Private Sub OpenExcel_Click()
Dim xlApp As Object
On Error Resume Next
Set xlAppp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
'Excel wasn't running, start it from code
Set xlApp = CreateObject("Excel.Application")
End If
On Error GoTo 0

xlAppp.Workbooks.Open ("C:\MS Access Databases\Export.xlsx")

objXL.Application.Visible = True
objXL.Parent.Windows(1).Visible = True
End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Note: GetObject or GetOpenFileName assumes you have already opened it AFAIK. If not, you'll need the CreateObject syntax. You can present the user with a folderpicker dialog to pick a file, or a filepicker dialog to select a file. Based on your post, I assume the application will not be open and you want the user to pick out a file, so the filedialog will be what you'll need. Either elaborate and provide more detail on the process, or research those two subjects and give it a go.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,829
Messages
6,162,229
Members
451,756
Latest member
tommyw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top