<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Excel to SAP Using VBscript - Invalid Character error in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-to-sap-using-vbscript-invalid-character-error/m-p/454819#M14029</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I´m not a SAP expert, but as you, I´ve tried to work with the code posted by Mariano but I could´t, the same error pops up...&lt;/P&gt;&lt;P&gt;After a few hours searching on google...I found this code on SlideShare,  I combined and adapted both &lt;/P&gt;&lt;P&gt;Now it´s working for me (on different TCODE)&lt;/P&gt;&lt;P&gt;Here I´ll copy-paste your code with the modifications, try with this and I hope it be helpful&lt;/P&gt;&lt;P&gt;Greetings&lt;/P&gt;&lt;P&gt;If Not IsObject(application) Then&lt;BR /&gt;  Set SapGuiAuto  = GetObject("SAPGUI")&lt;BR /&gt;  Set application = SapGuiAuto.GetScriptingEngine&lt;BR /&gt;End If&lt;BR /&gt;If Not IsObject(connection) Then&lt;BR /&gt;  Set connection = application.Children(0)&lt;BR /&gt;End If&lt;BR /&gt;If Not IsObject(session) Then&lt;BR /&gt;  Set session  = connection.Children(0)&lt;BR /&gt;End If&lt;BR /&gt;If IsObject(WScript) Then&lt;BR /&gt;  WScript.ConnectObject session,  "on"&lt;BR /&gt;  WScript.ConnectObject application, "on"&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;Dim objExcel,objWorkbook&lt;BR /&gt;Dim objSheet, intRow, i&lt;BR /&gt;Set objExcel  = CreateObject("Excel.Application") &lt;BR /&gt;Set objWorkbook = objExcel.Workbooks.open ("C:\Users\sularte\Downloads\Test_Role_Creation.xlsx")&lt;BR /&gt;Set objSheet = objExcel.Worksheets(1)&lt;BR /&gt;Row = 2&lt;BR /&gt;&lt;BR /&gt;session.findById("wnd[0]").maximize&lt;BR /&gt;session.findById("wnd[0]/tbar[0]/okcd").text = "/npfcg"&lt;BR /&gt;session.findById("wnd[0]").sendVKey 0&lt;BR /&gt;&lt;BR /&gt;Do Until objSheet.cells(Row,1).value=""&lt;BR /&gt;&lt;BR /&gt;session.findById("wnd[0]/usr/ctxtAGR_NAME_NEU").text = objSheet.Cells(Row,1).Value&lt;BR /&gt;session.findById("wnd[0]/usr/ctxtAGR_NAME_NEU").caretPosition = 16&lt;BR /&gt;session.findById("wnd[0]/usr/btn%#AUTOTEXT003").press&lt;BR /&gt;session.findById("wnd[0]/usr/txtS_AGR_TEXTS-TEXT").text = objSheet.Cells(Row,2).Value&lt;BR /&gt;session.findById("wnd[0]/usr/txtS_AGR_TEXTS-TEXT").caretPosition = 9&lt;BR /&gt;session.findById("wnd[0]").sendVKey 11&lt;BR /&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpTAB9").select&lt;BR /&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpTAB9/ssubSUB1:SAPLPRGN_TREE:0321/cntlTOOL_CONTROL/shellcont/shell").pressButton "TB03"&lt;BR /&gt;session.findById("wnd[1]/usr/tblSAPLPRGN_WIZARDCTRL_TCODE/ctxtS_TCODES-TCODE[0,0]").text = "su01d"&lt;BR /&gt;session.findById("wnd[1]/usr/tblSAPLPRGN_WIZARDCTRL_TCODE/ctxtS_TCODES-TCODE[0,0]").caretPosition = 5&lt;BR /&gt;session.findById("wnd[1]").sendVKey 0&lt;BR /&gt;session.findById("wnd[1]/tbar[0]/btn[19]").press&lt;BR /&gt;session.findById("wnd[0]").sendVKey 11&lt;BR /&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpTAB5").select&lt;BR /&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpTAB5/ssubSUB1:SAPLPRGN_TREE:0350/btnEXPERTE").press&lt;BR /&gt;session.findById("wnd[0]/usr/lbl[5,5]").setFocus&lt;BR /&gt;session.findById("wnd[0]/usr/lbl[5,5]").caretPosition = 1&lt;BR /&gt;session.findById("wnd[0]").sendVKey 2&lt;BR /&gt;session.findById("wnd[0]/usr/lbl[32,2]").setFocus&lt;BR /&gt;session.findById("wnd[0]/usr/lbl[32,2]").caretPosition = 0&lt;BR /&gt;session.findById("wnd[0]").sendVKey 2&lt;BR /&gt;session.findById("wnd[1]/tbar[0]/btn[0]").press&lt;BR /&gt;session.findById("wnd[0]").sendVKey 11&lt;BR /&gt;session.findById("wnd[1]/tbar[0]/btn[0]").press&lt;BR /&gt;session.findById("wnd[0]/tbar[1]/btn[17]").press&lt;BR /&gt;session.findById("wnd[0]/tbar[0]/btn[3]").press&lt;BR /&gt;session.findById("wnd[0]/tbar[0]/btn[3]").press&lt;BR /&gt;&lt;BR /&gt;Row = Row + 1&lt;BR /&gt;Loop&lt;BR /&gt;objExcel.Quit&lt;BR /&gt;Set objExcel = Nothing&lt;BR /&gt;Set objWorkbook = Nothing&lt;BR /&gt;Set objSheet = Nothing&lt;BR /&gt;msgbox (“Process Completed”)&lt;/P&gt;</description>
    <pubDate>Fri, 05 May 2017 14:19:49 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2017-05-05T14:19:49Z</dc:date>
    <item>
      <title>Excel to SAP Using VBscript - Invalid Character error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-to-sap-using-vbscript-invalid-character-error/m-p/454817#M14027</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;My purpose is to utilize VBscript to automatically create multiple roles (via transaction PFCG) based on an Excel input.&lt;/P&gt;&lt;P&gt;I recently found out about VBscript for SAP so I'm not that good in VB coding yet. &lt;/P&gt;&lt;P&gt;I have followed this tutorial, credits to &lt;SPAN class="mention-scrubbed"&gt;marianoc&lt;/SPAN&gt; for this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://blogs.sap.com/2014/08/04/script-recording-playback-for-dummies" target="test_blank"&gt;https://blogs.sap.com/2014/08/04/script-recording-playback-for-dummies&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Anyway, I've already recorded the process, and my excel file (which contains only two columns) is ready. &lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/26813-3.png" /&gt;&lt;/P&gt;&lt;P&gt;When I press the play button:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/26811-2.png" /&gt;&lt;/P&gt;&lt;P&gt;I encounter this error:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/26812-error-sap-1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My question is, what could be the cause of this error?&lt;/STRONG&gt; I'm sure this is not a syntax problem as I've religiously followed the guidelines of the tutorial.&lt;/P&gt;&lt;P&gt;Attaching the code here:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;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


Set objExcel = GetObject(,”Excel.Application”) 
Set objWrkbk = objExcel.OpenWorkbook("C:\Users\sularte\Downloads\Test_Role_Creation.xlsx")
Set objSheet = Sheets("Sheet1") 


For i = 2 to objSheet.UsedRange.Rows.Count 
	session.findById("wnd[0]/tbar[0]/okcd").text = "/npfcg"
	session.findById("wnd[0]").sendVKey 0
	session.findById("wnd[0]/usr/ctxtAGR_NAME_NEU").text = COL1
	session.findById("wnd[0]/usr/ctxtAGR_NAME_NEU").caretPosition = 16
	session.findById("wnd[0]/usr/btn%#AUTOTEXT003").press
	session.findById("wnd[0]/usr/txtS_AGR_TEXTS-TEXT").text = COL2
	session.findById("wnd[0]/usr/txtS_AGR_TEXTS-TEXT").caretPosition = 9
	session.findById("wnd[0]").sendVKey 11
	session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpTAB9").select
	session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpTAB9/ssubSUB1:SAPLPRGN_TREE:0321/cntlTOOL_CONTROL/shellcont/shell").pressButton "TB03"
	session.findById("wnd[1]/usr/tblSAPLPRGN_WIZARDCTRL_TCODE/ctxtS_TCODES-TCODE[0,0]").text = "su01d"
	session.findById("wnd[1]/usr/tblSAPLPRGN_WIZARDCTRL_TCODE/ctxtS_TCODES-TCODE[0,0]").caretPosition = 5
	session.findById("wnd[1]").sendVKey 0
	session.findById("wnd[1]/tbar[0]/btn[19]").press
	session.findById("wnd[0]").sendVKey 11
	session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpTAB5").select
	session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpTAB5/ssubSUB1:SAPLPRGN_TREE:0350/btnEXPERTE").press
	session.findById("wnd[0]/usr/lbl[5,5]").setFocus
	session.findById("wnd[0]/usr/lbl[5,5]").caretPosition = 1
	session.findById("wnd[0]").sendVKey 2
	session.findById("wnd[0]/usr/lbl[32,2]").setFocus
	session.findById("wnd[0]/usr/lbl[32,2]").caretPosition = 0
	session.findById("wnd[0]").sendVKey 2
	session.findById("wnd[1]/tbar[0]/btn[0]").press
	session.findById("wnd[0]").sendVKey 11
	session.findById("wnd[1]/tbar[0]/btn[0]").press
	session.findById("wnd[0]/tbar[1]/btn[17]").press
	session.findById("wnd[0]/tbar[0]/btn[3]").press
	session.findById("wnd[0]/tbar[0]/btn[3]").press
next
msgbox “Process Completed”


Set objSheet = Nothing
objWrkbk.close
Set objWrkbk = Nothing
objExcel.close
Set objExcel = Nothing
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;-Bagani&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 07:18:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-to-sap-using-vbscript-invalid-character-error/m-p/454817#M14027</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-03-28T07:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: Excel to SAP Using VBscript - Invalid Character error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-to-sap-using-vbscript-invalid-character-error/m-p/454818#M14028</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;in the tutorial you mention there are two code blocks which must be put in your script.&lt;/P&gt;&lt;P&gt;I don't see this lines in you code. Check the tutorial and look for e.g. "Block of code: Block A"&lt;/P&gt;&lt;P&gt;kind regards,&lt;/P&gt;&lt;P&gt;Bernhard&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 12:43:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-to-sap-using-vbscript-invalid-character-error/m-p/454818#M14028</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-03-29T12:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Excel to SAP Using VBscript - Invalid Character error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/excel-to-sap-using-vbscript-invalid-character-error/m-p/454819#M14029</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I´m not a SAP expert, but as you, I´ve tried to work with the code posted by Mariano but I could´t, the same error pops up...&lt;/P&gt;&lt;P&gt;After a few hours searching on google...I found this code on SlideShare,  I combined and adapted both &lt;/P&gt;&lt;P&gt;Now it´s working for me (on different TCODE)&lt;/P&gt;&lt;P&gt;Here I´ll copy-paste your code with the modifications, try with this and I hope it be helpful&lt;/P&gt;&lt;P&gt;Greetings&lt;/P&gt;&lt;P&gt;If Not IsObject(application) Then&lt;BR /&gt;  Set SapGuiAuto  = GetObject("SAPGUI")&lt;BR /&gt;  Set application = SapGuiAuto.GetScriptingEngine&lt;BR /&gt;End If&lt;BR /&gt;If Not IsObject(connection) Then&lt;BR /&gt;  Set connection = application.Children(0)&lt;BR /&gt;End If&lt;BR /&gt;If Not IsObject(session) Then&lt;BR /&gt;  Set session  = connection.Children(0)&lt;BR /&gt;End If&lt;BR /&gt;If IsObject(WScript) Then&lt;BR /&gt;  WScript.ConnectObject session,  "on"&lt;BR /&gt;  WScript.ConnectObject application, "on"&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;Dim objExcel,objWorkbook&lt;BR /&gt;Dim objSheet, intRow, i&lt;BR /&gt;Set objExcel  = CreateObject("Excel.Application") &lt;BR /&gt;Set objWorkbook = objExcel.Workbooks.open ("C:\Users\sularte\Downloads\Test_Role_Creation.xlsx")&lt;BR /&gt;Set objSheet = objExcel.Worksheets(1)&lt;BR /&gt;Row = 2&lt;BR /&gt;&lt;BR /&gt;session.findById("wnd[0]").maximize&lt;BR /&gt;session.findById("wnd[0]/tbar[0]/okcd").text = "/npfcg"&lt;BR /&gt;session.findById("wnd[0]").sendVKey 0&lt;BR /&gt;&lt;BR /&gt;Do Until objSheet.cells(Row,1).value=""&lt;BR /&gt;&lt;BR /&gt;session.findById("wnd[0]/usr/ctxtAGR_NAME_NEU").text = objSheet.Cells(Row,1).Value&lt;BR /&gt;session.findById("wnd[0]/usr/ctxtAGR_NAME_NEU").caretPosition = 16&lt;BR /&gt;session.findById("wnd[0]/usr/btn%#AUTOTEXT003").press&lt;BR /&gt;session.findById("wnd[0]/usr/txtS_AGR_TEXTS-TEXT").text = objSheet.Cells(Row,2).Value&lt;BR /&gt;session.findById("wnd[0]/usr/txtS_AGR_TEXTS-TEXT").caretPosition = 9&lt;BR /&gt;session.findById("wnd[0]").sendVKey 11&lt;BR /&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpTAB9").select&lt;BR /&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpTAB9/ssubSUB1:SAPLPRGN_TREE:0321/cntlTOOL_CONTROL/shellcont/shell").pressButton "TB03"&lt;BR /&gt;session.findById("wnd[1]/usr/tblSAPLPRGN_WIZARDCTRL_TCODE/ctxtS_TCODES-TCODE[0,0]").text = "su01d"&lt;BR /&gt;session.findById("wnd[1]/usr/tblSAPLPRGN_WIZARDCTRL_TCODE/ctxtS_TCODES-TCODE[0,0]").caretPosition = 5&lt;BR /&gt;session.findById("wnd[1]").sendVKey 0&lt;BR /&gt;session.findById("wnd[1]/tbar[0]/btn[19]").press&lt;BR /&gt;session.findById("wnd[0]").sendVKey 11&lt;BR /&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpTAB5").select&lt;BR /&gt;session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpTAB5/ssubSUB1:SAPLPRGN_TREE:0350/btnEXPERTE").press&lt;BR /&gt;session.findById("wnd[0]/usr/lbl[5,5]").setFocus&lt;BR /&gt;session.findById("wnd[0]/usr/lbl[5,5]").caretPosition = 1&lt;BR /&gt;session.findById("wnd[0]").sendVKey 2&lt;BR /&gt;session.findById("wnd[0]/usr/lbl[32,2]").setFocus&lt;BR /&gt;session.findById("wnd[0]/usr/lbl[32,2]").caretPosition = 0&lt;BR /&gt;session.findById("wnd[0]").sendVKey 2&lt;BR /&gt;session.findById("wnd[1]/tbar[0]/btn[0]").press&lt;BR /&gt;session.findById("wnd[0]").sendVKey 11&lt;BR /&gt;session.findById("wnd[1]/tbar[0]/btn[0]").press&lt;BR /&gt;session.findById("wnd[0]/tbar[1]/btn[17]").press&lt;BR /&gt;session.findById("wnd[0]/tbar[0]/btn[3]").press&lt;BR /&gt;session.findById("wnd[0]/tbar[0]/btn[3]").press&lt;BR /&gt;&lt;BR /&gt;Row = Row + 1&lt;BR /&gt;Loop&lt;BR /&gt;objExcel.Quit&lt;BR /&gt;Set objExcel = Nothing&lt;BR /&gt;Set objWorkbook = Nothing&lt;BR /&gt;Set objSheet = Nothing&lt;BR /&gt;msgbox (“Process Completed”)&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 14:19:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/excel-to-sap-using-vbscript-invalid-character-error/m-p/454819#M14029</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-05-05T14:19:49Z</dc:date>
    </item>
  </channel>
</rss>

