Showing results for 
Search instead for 
Did you mean: 

End with without with caused by excel info extraction - How to fix it?

0 Kudos

I'm trying to grab info from Excel to paste into SAP with SAP GUI and I keep encountering the issue "End with without with". I noticed that by making into 'text lines 4 to 9 the problem is solved. What am I missing?

With SAPSession

    Dim objExcel
    Dim objSheet, intRow, i
  'End with without with  issue start:
    Set objExcel = GetObject(, "Excel.Application")
    Set objSheet = objExcel.ActiveWorkbook.ActiveSheet
    For i = 2 To objSheet.UsedRange.Rows.Count
    cOL1 = Trim(CStr(objSheet.Cells(i, 1).Value))
    cOL2 = Trim(CStr(objSheet.Cells(i, 2).Value))
    cOL3 = Trim(CStr(objSheet.Cells(i, 3).Value))
  'End of the issue last 6 lines

    .findById("wnd[0]/tbar[0]/okcd").Text = "/nZFFSCMCOMMENTS"
    .findById("wnd[0]").sendVKey 0
    .findById("wnd[0]/usr/chkP_OPEN").Selected = True
    .findById("wnd[0]/usr/chkP_CLOSED").Selected = True
    .findById("wnd[0]/usr/ctxtP_BUKRS").Text = "003"
    .findById("wnd[0]/usr/ctxtS_KUNNR-LOW").Text = cOL1
    .findById("wnd[0]/usr/txtS_DOCNO-LOW").Text = cOL2
    .findById("wnd[0]/usr/ctxtS_CREDAT-LOW").Text = Cells(7, 1).Value
    .findById("wnd[0]/usr/ctxtS_CREDAT-HIGH").Text = Cells(7, 2).Value
    .findById("wnd[0]/usr/ctxtP_ALVVAR").Text = "/pdi"
    .findById("wnd[0]/usr/ctxtP_ALVVAR").caretPosition = 4
End With
Community Manager
Community Manager
0 Kudos

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with, as it provides tips for preparing questions that draw responses from our members. Feel free to take our Q&A tutorial at as well, 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:

Kind regards,


Moderation Lead

Active Contributor
0 Kudos

Where is the "next" to end the "for" ?

Accepted Solutions (0)

Answers (0)