Guest User

AutoAttachExample

a guest
Sep 20th, 2016
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub AttachExample()
  2.  
  3. 'Establish Connection to SAP
  4. Dim App, Connection, session As Object
  5. Set SapGuiAuto = GetObject("SAPGUI")
  6. Set App = SapGuiAuto.getscriptingEngine
  7. Set Connection = App.Children(0)
  8. Set session = Connection.Children(0)
  9.  
  10. 'Open the item to attach documentation
  11. session.starttransaction "IL03"
  12. session.findById("wnd[0]/usr/ctxt[0]").Text = Sheets("Sheet1").Range("DocNumber").Value
  13. session.findById("wnd[0]/usr/ctxt[1]").Text = Sheets("Sheet1").Range("DocYear").Value
  14. session.findById("wnd[0]").sendVKey 0
  15.  
  16.  
  17.  
  18. 'Open up the SAP dialog box
  19. session.findById("wnd[0]/titl/shellcont/shell").PressContextButton "%GOS_TOOLBOX"
  20. session.findById("wnd[0]/titl/shellcont/shell").SelectContextMenuItem "%GOS_PCATTA_CREA"
  21.  
  22. 'Input the file path and file name to attach
  23. session.findById("wnd[1]/usr/ctxt[0]").Text = Sheets("Sheet1").Range("FilePath").Value
  24. session.findById("wnd[1]/usr/ctxt[1]").Text = Sheets("Sheet1").Range("FileName").Value
  25.  
  26. End Sub
Advertisement
Add Comment
Please, Sign In to add comment