on 08-19-2018 12:48 AM
Hi, I have a problem, I'm writing a script to save an attachment from VF03, this script takes information from excel, but I have a problem when the script goes into the application and tries to export the SAP, take some number from excel and replace this number with the file name without format,
in the application there can be two formats .zip or .pdf, but I can not know what format will be now. Is there any problem with copying the format from the file name, inserting text from Excel and the insertion format?
Maybe there is still some solution?
My goal is to save the document with the correct name from the table and with the correct extension
My code
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\Z003S0BF\Desktop\My_scripts\VF03_mass_download\Book3.xlsx")
Set objSheet = objWorkbook.Sheets("Sheet1")
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 = "VF03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtVBRK-VBELN").text = COL1
session.findById("wnd[0]/usr/ctxtVBRK-VBELN").caretPosition = 10
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"
session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_VIEW_ATTA"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectedRows = "0"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").pressToolbarButton "%ATTA_EXPORT"
session.findById("wnd[2]/usr/ctxtDY_PATH").text = COL3
session.findById("wnd[2]/usr/ctxtDY_FILENAME").text = COL2
session.findById("wnd[2]/usr/ctxtDY_PATH").setFocus
session.findById("wnd[2]/usr/ctxtDY_PATH").caretPosition = 67
session.findById("wnd[2]/tbar[0]/btn[11]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
next
msgbox "Process Complete"
assuming I understand what you are wanting...
COL2 = session.findById("wnd[2]/usr/ctxtDY_FILENAME").text + COL2
session.findById("wnd[2]/usr/ctxtDY_FILENAME").text = COL2
you may need to concatenate a slash in there too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.