Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub AttachExample()
- 'Establish Connection to SAP
- Dim App, Connection, session As Object
- Set SapGuiAuto = GetObject("SAPGUI")
- Set App = SapGuiAuto.getscriptingEngine
- Set Connection = App.Children(0)
- Set session = Connection.Children(0)
- 'Open the item to attach documentation
- session.starttransaction "IL03"
- session.findById("wnd[0]/usr/ctxt[0]").Text = Sheets("Sheet1").Range("DocNumber").Value
- session.findById("wnd[0]/usr/ctxt[1]").Text = Sheets("Sheet1").Range("DocYear").Value
- session.findById("wnd[0]").sendVKey 0
- 'Open up the SAP dialog box
- session.findById("wnd[0]/titl/shellcont/shell").PressContextButton "%GOS_TOOLBOX"
- session.findById("wnd[0]/titl/shellcont/shell").SelectContextMenuItem "%GOS_PCATTA_CREA"
- 'Input the file path and file name to attach
- session.findById("wnd[1]/usr/ctxt[0]").Text = Sheets("Sheet1").Range("FilePath").Value
- session.findById("wnd[1]/usr/ctxt[1]").Text = Sheets("Sheet1").Range("FileName").Value
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment