-2

I'm tying to automate a certain process in SAP GUI. But I can't get the script this specific part.

It reads until I double click in this field shown in color green.

enter image description here

After that the following window is opened:

enter image description here

How do I get this number in VBA? Any ideas?

  • 1
    This is part of the [GuiStatusBar object](https://help.sap.com/docs/search?q=GuiStatusBart&product=sap_gui_for_windows) which you can obtain using `session.ActiveWindow.findById("sbar")`, and then you can use the property `Text` which contains the short text "O documento ... lançado". The documentation talks about the property `MessageParameter` but using VBScript I always get the String value "Parameter not optional." (test with SAP GUI 7.70) – Sandra Rossi Feb 08 '23 at 16:36
  • Thanks! I didn't know exactly what was that name but now I can look search for something. I didn't test this you mentioned because only in company I have access to SAP. – Lucas Tezolini Feb 09 '23 at 00:57
  • Hi, Sandra. I could get the text! Thanks!! Set sStatusBar = session.findById("wnd[0]/sbar") Range("D6").Value = sStatusBar.Text Set sStatusBar = session.findById("wnd[0]/sbar") – Lucas Tezolini Feb 09 '23 at 10:15
  • 1
    `session.ActiveWindow.findById("sbar")` also works, it's very useful because you don't need to worry about the window number (`0` in your case). Simplification for getting just the text: `xxxx = `session.ActiveWindow.findById("sbar").Text`. – Sandra Rossi Feb 09 '23 at 12:50

1 Answers1

2

This should work everywhere in Excel VBA(docNumber is your result):

Dim objRegEx As Object
Dim theMatches As Object
Dim statusPanel As String
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.IgnoreCase = True
objRegEx.Global = True

objRegEx.Pattern = "[^\D]+"
statusPanel = session.FindById("wnd[0]/sbar/pane[0]").Text
Set theMatches = objRegEx.Execute(statusPanel)

For Each Match In theMatches
  docNumber = Match.Value
Next
Stefan
  • 51
  • 6