Skip to Content

VB Script error message "Unable to write read-only property

Apr 24 at 02:05 PM


avatar image
Former Member

Hi, As you can see the below program to create a simple BA but when included additional line of code to accommodate excel spread sheet for mass BA creation actually locks the spreadsheet to read only which is preventing the script to run through. Please help. Thanks

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, objWorkbook, objSheet, i Set objExcel = CreateObject("Excel.Application") Set objWorkbook = objExcel.Workbooks.Open("C:\Users\TSK\Documents\BA06.xlsx") Set objSheet = objWorkbook.Sheets("Sheet1") For i = 2 to objSheet.UsedRange.Rows.Count Business = Trim(CStr(objSheet.Cells(i, 1).Value)) 'Column1 Name = Trim(CStr(objSheet.Cells(i, 2).Value)) 'Column2 session.findById("wnd[0]/tbar[0]/okcd").text = "ox03" session.findById("wnd[0]").sendVKey 0 session.findById("wnd[0]/tbar[1]/btn[5]").press session.findById("wnd[0]/usr/tblSAPL0ORGCORETCTRL_V_TGSB/txtV_TGSB-GSBER[0,0]").text = Business session.findById("wnd[0]/usr/tblSAPL0ORGCORETCTRL_V_TGSB/txtV_TGSB-GTEXT[1,0]").text = Name session.findById("wnd[0]/usr/tblSAPL0ORGCORETCTRL_V_TGSB/txtV_TGSB-GTEXT[1,0]").setFocus session.findById("wnd[0]/usr/tblSAPL0ORGCORETCTRL_V_TGSB/txtV_TGSB-GTEXT[1,0]").caretPosition = 19 session.findById("wnd[0]/tbar[0]/btn[11]").press next msgbox "BA Created"

10 |10000 characters needed characters left characters exceeded
Former Member

Can some help me with the code locking the spreadsheet. Thanks

* Please Login or Register to Answer, Follow or Comment.

0 Answers