Showing results for 
Search instead for 
Did you mean: 

Excel VBA Loop Function: FB05

0 Kudos

Hi all,

I want to help my team save precious time by removing the manual encoding process in FB05.

I've been trying to look for loop function in encoding that will only finish the loop until the last blank row (column AC)

Here is my code:

Dim SapGuiAuto As Object

Dim application As Object 'SAPFEWSELib.GuiApplication

Dim connection As Object 'SAPFEWSELib.GuiConnection

Dim session As Object 'SAPFEWSELib.GuiSession

Set SapGuiAuto = GetObject("SAPGUI")

Set application = SapGuiAuto.GetScriptingEngine

Set connection = application.Children(0)

Set session = connection.Children(0)

session.FindById("wnd[0]/usr/ctxtRF05A-NEWBS").Text = "09"

session.FindById("wnd[0]/usr/ctxtRF05A-NEWKO").Text = Cells(2, "AC")

session.FindById("wnd[0]/usr/ctxtRF05A-NEWUM").Text = "9"


session.FindById("wnd[0]/usr/ctxtRF05A-NEWUM").CaretPosition = 1

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

session.FindById("wnd[0]/usr/txtBSEG-WRBTR").Text = Cells(2, "T")

session.FindById("wnd[0]/usr/ctxtBSEG-ZFBDT").Text = "10/20/2022"

session.FindById("wnd[0]/usr/txtBSEG-VERTN").Text = Cells(2, "AD")

session.FindById("wnd[0]/usr/ctxtBSEG-VERTT").Text = "9"

session.FindById("wnd[0]/usr/ctxtBSEG-SGTXT").Text = Cells(2, "AE")


session.FindById("wnd[0]/usr/ctxtRF05A-NEWBS").CaretPosition = 0

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, 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, 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:

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.

* Share screenshots of what you've seen/done (if possible), as images always helps our members better understand your problem.

* 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. As it stands, I don't know if there is enough information here for members to understand your issue. So please consider revising your question because I'd really like to see you get a solution to your problem!

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



View Entire Topic
0 Kudos


As it is very specific to Excel VBA programing, I would recommend you consult Microsoft for more help, because I think they have more expertise on this topic.

Best regards,