Run time error with vba in Acess runtime 2013.

sashapixie

Board Regular
Joined
Aug 29, 2013
Messages
71
Office Version
  1. 365
Platform
  1. Windows
Hi There

I have the following code set up in my full version of Access 2013.

Private Sub Contract_Number_AfterUpdate()

'Open As the crow flys message box
If MsgBox("Would you like to update the 'as the crow flys' file now?", vbQuestion Or vbYesNo, "Information Update Request!") = vbYes Then

'Open Excel
Dim xlTmp As Excel.Application
Set xlTmp = New Excel.Application

'Open As the crow flys file
xlTmp.Workbooks.Open "Z:\#Accounts\As The Crow Flies\As The Crow Flies.xlsx"
xlTmp.Visible = True
xlTmp.ActiveWindow.WindowState = 2

'Clean up code
Set xlTmp = Nothing

End If
End Sub

I have colleagues who have Access 2013 runtime installed on their machines, when I run this code on their machines I get the following error message and then database promptly closes.

I'm at a loss on how to fix this, any help would be greatly appreciated.

"Execution of this application has stopped due to a run-time error."
"The application can't continue and will be shut down"
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
sorry, but RUNTIME WONT work with excel object via code.
I have tried , and tried.
but it wont with runtime.

What i did was have a macro IN the excel wb.
Open the excel wb via SHELL thru access, then the macro would autorun.
 
Last edited:
Upvote 0
Hi Ranman256

Thank you for your comment, I have amended the code as per the below, however I am still struggling to open the file.

Please bear with me as I have not used the Shell function before.

Private Sub Contract_Number_AfterUpdate()
Dim CrowFly As Variant

'Open As the crow flys message box
If MsgBox("Would you like to update the 'as the crow flys' file now?", vbQuestion Or vbYesNo, "Information Update Request!") = vbYes Then

CrowFly = Shell("Z:\#Accounts\As The Crow Flies\As The Crow Flies.xlsx" , 1)

End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,849
Messages
6,162,425
Members
451,765
Latest member
craigvan888

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