Reputation: 8942
First of all, I have searched and read similar threads and I have tried the solutions that were proposed and solved the other people's problem (mostly using single quotes around the workbook name) but it hasn't worked in my case.
What I want to do is very simple: I want to call an Excel workbook from Access. The workbook is already open (using VBA) so this is not an issue of the workbook being closed. Here is how I attempt to run the macro:
Application.Run "'" & xlWb.Path & "\" & xlWb.Name & "'" & "!mainParcourirTrouverItem"
Results in:
'I:\47491\...\Trouver items global.xlsm'!mainParcourirTrouverItem
I have tried a few variations like not using the complete path (only file name), not using single quotes, adding parentheses at the end of the sub's name...
Also, I have double-checked that the spelling of the sub name is actually correct. I really don't see it :|
Oh and just for the sake of giving context, here is the complete sub surrounding this code:
Private Sub Commande10_Click()
Dim xlApp As Excel.Application
Dim xlWb As Excel.Workbook
Set xlApp = New Excel.Application
With xlApp
.Visible = False
Set xlWb = .Workbooks.Open(FichierImportExcel, ReadOnly:=True)
End With
Application.Run "'" & xlWb.Path & "\" & xlWb.Name & "'" & "!mainParcourirTrouverItem"
' Call importer_transitsrubriques_Click
End Sub
Many thanks.
Upvotes: 1
Views: 8241
Reputation: 166790
xlApp.Run
not Application.Run
Application
will refer to Access, not Excel.
Upvotes: 6