Hi guys!
I am currently developing a macro tool wherein I can export the attachment of a document using FB03 and saving it in a specific folder.
I was able to create one but I have the following problem:
> I don't know why there is an error with the path of the file whenever I try to link specific paths to a cell from my excel. But when I input the path directly to the VBA, it works. (hope this question was clear.
)
> I am a VBA beginner so I would like to loop this macro and I want it to perform the export for a list of documents and not just one.
> Is it possible for me to insert the exported file into the excel sheet next to the document number?
Hope I was clear with what intend to do...Please help. ![]()
THANK YOU SO MUCH!!
Below are the details that I have in my Excel sheet
| A | B | C | |
1 | Destination File | C:\Users\LIX2628\Desktop\PUll outs export\ | | |
2 | Document Number | Co. Code | Year | |
| 1200072996 | u001 | 2014 |
And below is the script that I used.
Sub FB03export()
Dim application
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]").resizeWorkingPane 196, 15, False
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nfb03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/txtRF05L-BELNR").Text = Cells(3, 2).Value
session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").Text = Cells(3, 3).Value
session.findById("wnd[0]/usr/txtRF05L-GJAHR").Text = Cells(3, 4).Value
session.findById("wnd[0]/usr/txtRF05L-GJAHR").SetFocus
session.findById("wnd[0]/usr/txtRF05L-GJAHR").caretPosition = 4
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").currentCellColumn = "BITM_DESCR"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectedRows = "0"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").contextMenu
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectContextMenuItem "%BDS_START_BDN"
session.findById("wnd[0]/shellcont[1]/shell").selectedNode = "Doc-00000001"
session.findById("wnd[0]/mbar/menu[0]/menu[6]").Select
session.findById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[0,21]").Text = "C:\Users\LIX2628\Desktop\PUll outs export\"
session.findById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[0,21]").caretPosition = 42
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[1]/tbar[0]/btn[12]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
End Sub