cancel
Showing results for 
Search instead for 
Did you mean: 

How to select path from dropdown list while saving the report in SAP using VBA script?

0 Kudos
337

Hi There, I'm trying to take a export using VBA SAP GUI script and wanted to save a extract in .xlsx format from the List menu bar but it is not letting me save to the desired path.

Below is the code that i wrote as per my logics. Would be great if someone can help me to fix the script as per the requirement.

Sub SAPTCode()

Dim SapGuiAuto, Application, Connection, session As Object, wb As Workbook

Set SapGuiAuto = GetObject("SAPGUI")

Set Application = SapGuiAuto.GetScriptingEngine

Set Connection = Application.Children(0)

Set session = Connection.Children(0)

'Dim Carrid As String

session.FindById("wnd[0]").Maximize

session.FindById("wnd[0]/tbar[0]/okcd").Text = "FBL1N"

session.FindById("wnd[0]").SendVKey 0

session.FindById("wnd[0]/usr/ctxtKD_BUKRS-LOW").Text = " "

session.FindById("wnd[0]/usr/ctxtKD_BUKRS-LOW").SetFocus

session.FindById("wnd[0]/usr/ctxtKD_BUKRS-LOW").CaretPosition = 4

session.FindById("wnd[0]/tbar[1]/btn[8]").Press

session.FindById("wnd[0]/mbar/menu[0]/menu[3]/menu[1]").Select

session.FindById("wnd[0]/tbar[0]/btn[0]").Press

session.FindById("wnd[0]/usr/lbl[36,1]").SetFocus

session.FindById("wnd[0]/usr/lbl[36,1]").CaretPosition = 73

session.FindById("wnd[1]/usr/ctxtDY_SAVEIN/DROPDOWN/DOCUMENTS").Select

session.FindById("wnd[1]/usr/ctxtDY_FILENAME").Text = "Test.xlsx"

session.FindById("wnd[1]/usr/ctxtDY_FILENAME").CaretPosition = 27

session.FindById("wnd[1]/tbar[0]/btn[0]").Press

session.FindById("wnd[0]/tbar[0]/btn[15]").Press

End Sub

moshenaveh
Community Manager
Community Manager
0 Kudos

Welcome to the SAP Community. Thank you for visiting us to get answers to your questions.

Since you're asking a question here for the first time, I'd like to offer some friendly advice on how to get the most out of your community membership and experience.

First, please see https://community.sap.com/resources/questions-and-answers, as this resource page provides tips for preparing questions that draw responses from our members. Second, feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html, as that will help you when submitting questions to the community.

I also recommend that you include a profile picture. By personalizing your profile, you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html.

Now for some specific suggestions on how you might improve your question:

* Outline what steps you took to find answers (and why they weren't helpful) -- so members don't make suggestions that you've already tried.

* Make sure you've applied the appropriate tags -- because if you don't apply the correct tags, the right experts won't see your question to answer it.

* Use the "insert code" feature when sharing your code, so members have an easier time reading.

Should you wish, you can revise your question by selecting Actions, then Edit.

The more details you provide (in questions tagged correctly), the more likely it is that members will be able to respond.

I hope you find this advice useful, and we're happy to have you as part of SAP Community!

Accepted Solutions (0)

Answers (1)

Answers (1)

FrankKrauseGUI
Product and Topic Expert
Product and Topic Expert

Hello Shubham,

the dialog you are showing is a Windows dialog. Such dialogs cannot be used via SAP GUI Scripting - you would need some other automation approach for being able to work with them. Therefore, there is an option in SAP GUI for Windows which lets you replace such dialogs by ABAP dialog boxes (which are not as user friendly, but can be scripted). See the option called "Show native Microsoft Windows Dialogs" here: https://help.sap.com/docs/sap_gui_for_windows/63bd20104af84112973ad59590645513/7ddb7c9c4a4c43219a65e.... This option needs to be deactivated.

Best regards,
Frank