Can anyone tell me how I can simulate clicking this command button on
the spreadsheet through VBA from Access?
Or is there another way to approach this such as creating a public
procedure in the spreadsheet which can be called from Access?
Your assistance is very much appreciated.
Oliver
That's right. Change the event procedure from Private to Public, then
call it like any other public procedure.
-Tom.
I'm struggling to call a public procedure in a standard module in
Excel from Access, can anyone tell me why the following code does not
work?
In the Excel spreadsheet I have declared the following public function
in a standard module 'PubFns':
Public Function pubintTest()
pubintTest = 100
End Function
In an Access database I have the following subroutine:
Public Sub pubsubRunProc()
Dim xlapp As Excel.Application
Dim xlwkb As Excel.Workbook
Dim intX As Integer
Set xlapp = New Excel.Application
xlapp.Visible = True
Set xlwkb = xlapp.Workbooks.Open("C:\Test1.xls")
intX = xlapp.pubintTest
Debug.Print intX
End Sub
When I run pubsubRunProc from the Immediate window the spreadsheet
opens but I get the error message: "Run-time error '438' Object
doesn't support this property or method"
Any assistance would be appreciated.
Cheers,
Oliver
I got an example to work using the same code as yours except I used:
intX = xlapp.Application.Run("pubintTest")
That idea came from recording a macro that ran a macro.
James A. Fortune
CDMAP...@FortuneJames.com
That works perfectly thank you.
I also had a case where I had to pass a parameter to the called
procedure. For this I used the following syntax:
intX = xlapp.Application.Run "pubintTest", "1"
In other words, without the brackets.