Hello Fivewinners,
I have inserted a button in an Excel xls-File which invokes a Visual-Basic routine.
how can I invoke this routine cmdButton_Click() with ole?
best regards, Norbert
Jeff Barnes wrote:Norbert,
I don't know if this will help but you can try to record a macro, then click your button. Now edit the macro and look at the code, it might give you an idea as to how to incoke from FW.
Jeff
Gale FORd wrote:Try recording a macro.
Then record another macro that runs the first macro.
Then debug code and you will find something like
Application.Run "Book1!Macro1"
Maybe this gives you a clue.
Private Sub cmdCreateBeleg_Click()
If (bOLAnmeldung) Then
'MsgBox "Anmeldung erfolgreich"
bAngemeldet = True
End If
ReadCells
If bAngemeldet Then
bOk = bSetBelegKopf
bOk = bSetPositionen
bOk = bSaveBeleg
WriteErgebnis
Else
' MsgBox "Sie sind nicht an der Office Line angemeldet."
End If
Clear
End Sub
Gale FORd wrote:Why not put the code that is now in cmdCreateBeleg_Click() in a macro.
Then call the macro from cmdCreateBeleg_Click(), and from external program.
Gale FORd wrote:Why not put the code that is now in cmdCreateBeleg_Click() in a macro.
Then call the macro from cmdCreateBeleg_Click(), and from external program.
function test()
oExcel := TOleAuto():New("Excel.Application")
oExcel:WorkBooks:Open( "H:\My Documents\test.xls" )
oExcel:Visible := .t.
oExcel:Run( "test.xls!Sheet1.CommandButton1_Click" )
return( .t. )
Sub CommandButton1_Click()
MsgBox "Sie sind nicht an der Office Line angemeldet."
End Sub
Gale FORd wrote:This works for me.
- Code: Select all Expand view
function test()
oExcel := TOleAuto():New("Excel.Application")
oExcel:WorkBooks:Open( "H:\My Documents\test.xls" )
oExcel:Visible := .t.
oExcel:Run( "test.xls!Sheet1.CommandButton1_Click" )
return( .t. )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 74 guests