Link from excel to SAP

Ivica

Board Regular
Joined
Jan 16, 2004
Messages
57
How can I insert a link on command button (or another way) to start another application from Excel?
Using some kind of Hyperlink or....
What other ways are to call another applications from Excel and start as a new application?


Thanx
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

MartinK

Active Member
Joined
Oct 30, 2003
Messages
384
Howdy!

For instance, this will start Word:
Code:
Private Sub cmdCommandButton1_Click()
    On Error Resume Next
    Set wrdApp = GetObject("Word.Application")
    If Err.Number <> 0 Then Set wrdApp = CreateObject("Word.Application")
    On Error GoTo 0
    wrdApp.Visible = True
End Sub

and this will start WCalculator:
Code:
Sub StartCalculator()
    AppFile = "Calc.exe"
    On Error Resume Next
    AppActivate ("Calculator")
    If Err <> 0 Then
        Err = 0
        CalcTaskID = Shell(AppFile, 1)
        If Err <> 0 Then MsgBox ("Can't start Calculator")
    End If
End Sub

But probably forget SAP, you will not get the rights from your db administrator to access directly the normalized tables. SAP is a system that works strictly with transaction and they probably won't let you to remote-control this process via VBA. I tried for a long time and I had to give up in the end. :oops:

Best,
Martin
 

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
Been here, done that (with SAP). My application opened emails and transfered data to SAP. If you are expecting a faultless operation don't start, you will not get it. The final result was relatively unreliable because things (like opening menus or changing dialog view) take some time to happen on screen. Despite putting Waits in the code there were still crashes at times when the server was extra slow. Despite all this, the user was happier with it than without.

I was unable to use Shell to open SAP because the method was controlled by our IT department, as well as requiring passwords, so opened manually and went from there. The principle is to 'fool' SAP into accepting Virtual Key commands from the macro rather than the keyboard. Sendkeys, for some reason, was unreliable so had to use API calls to mimic keyboard action which is basically 2 events - keydown and keyup. So you have to do things like tab to a textbox, select the data there, and Ctrl+C to copy - all with the keyboard.

I am happy to email you with a copy of my code as is, but not to spend a lot of time explaining or supporting it. It is pretty well commented. This is far from a trivial undertaking, especially as it is not possible to debug code by stepping through line by line - because in this case the VB Editor becomes the active window and Virtual Key strokes are applied there. If you do want the code, just send me a PM with your email address.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,883
Messages
5,766,926
Members
425,386
Latest member
DougFarley

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
Top