call visual-basic routin in an excel .xls
call visual-basic routin in an excel .xls
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
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
- Posts: 933
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
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.
Unfortunately, this doesn't work either since the keystroke isn't recorded in the macro.
I would like simply to fill a table with values and then reprocess these data by a routine which I have put on a key.
Code: Select all | Expand
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
Isn't it possible to start a Visual-BASIC routine with OLE, then?
Norbert
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.
Because within this routine further Functionen are invoked.
I have tested it. An error message "Function or Sub not defined" then comes
Norbert
This works for me.
Code: Select all | Expand
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. )
Here is the code for my button in sheet1
Code: Select all | Expand
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
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. )
It works. Many thanks to you.
Norbert