none
Error: Expected End of Statement RRS feed

  • Question

  • Hello,

    Please help, I am doing a COA printing using QC22 by Sap Gui Scripting.

    I'm not yet good in vbs. below is my recording and having an error: Expected End of Statement.

    Kindly correct what is the missing and error of below codes. Thank you so much.

    If Not IsObject(application) Then
       Set SapGuiAuto  = GetObject("SAPGUI")
       Set application = SapGuiAuto.GetScriptingEngine
    End If
    If Not IsObject(connection) Then
       Set connection = application.Children(0)
    End If
    If Not IsObject(session) Then
       Set session    = connection.Children(0)
    End If
    If IsObject(WScript) Then
       WScript.ConnectObject session,     "on"
       WScript.ConnectObject application, "on"

    End If

    session.findById("wnd[0]").maximize


    Dim objExcel As Excel.Application

    Dim objSheet, intRow, i

    Set objExcel = GetObject(,"C:\TEMP\COA\Book1.xlsx")

    Set objSheet = objExcel.ActiveWorkbook.ActiveSheet


    For i = 2 to objSheet.UsedRange.Rows.Count

    cOL1 = Trim(CStr(objSheet.Cells(i, 1).Value)) 'Column1

    cOL2 = Trim(CStr(objSheet.Cells(i, 2).Value)) 'Column2

    cOL3 = Trim(CStr(objSheet.Cells(i, 3).Value)) 'Column3


    session.findById("wnd[0]/tbar[0]/okcd").text = "/nqc22"
    session.findById("wnd[0]/tbar[0]/btn[0]").press
    session.findById("wnd[0]/usr/ctxtP_MATNR").text = cOL1
    session.findById("wnd[0]/usr/ctxtP_CHARG").text = cOL2
    session.findById("wnd[0]/usr/ctxtP_WERKS").text = cOL3
    session.findById("wnd[0]/usr/ctxtP_WERKS").setFocus
    session.findById("wnd[0]/usr/ctxtP_WERKS").caretPosition = 4
    session.findById("wnd[0]/usr/btn%P200014_1000").press
    session.findById("wnd[1]/usr/radQCPARTYPE-X_NONE").select
    session.findById("wnd[1]/usr/radQCPARTYPE-X_NONE").setFocus
    session.findById("wnd[1]/tbar[0]/btn[0]").press
    session.findById("wnd[0]/usr/cmbP_MEDIUM").key = "1"
    session.findById("wnd[0]/usr/cmbP_MEDIUM").setFocus
    session.findById("wnd[0]/tbar[1]/btn[8]").press

    Next

    MsgBox = "The certificate was created."

    End IF

    Saturday, February 3, 2018 3:41 PM

Answers

All replies