Quantcast
Channel: SCN : Discussion List - Scripting Languages
Viewing all articles
Browse latest Browse all 325

Attaching documents in FB03

$
0
0

Hello Dears,

 

I hope you can help me with my problem.

 

I am trying to do a VBA macro in Excel and goal is to attach a file in a document number.

I have recorded a script in SAP and edited it, but the pop-up box won't direct to my file path and I have to click the attachment everytime the macro runs.

 

Here's the script of my macro.

______

 

 

Sub Picture1_Click()

'

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 = Connect

ion.Children (0)

End If

If IsObject(WScript) Then

   WScript.ConnectObject session, "on"

   WScript.ConnectObject application, "on"

End If

 

 

LG = 3

 

 

Do While Range("A" & LG) > ""

 

 

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

session.findById("wnd[0]/tbar[0]/okcd").Text = "/nfb03"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/txtRF05L-BELNR").Text = Range("A" & LG)

session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").Text = Range("B" & LG)

session.findById("wnd[0]/usr/txtRF05L-GJAHR").Text = Range("C" & LG)

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_PCATTA_CREA"

 

 

LG = LG + 1

Loop

 

 

MsgBox UCase(Environ("username")) & ": Done attaching."

 

 

End Sub

 

___

 

I hope you can help me so I won't have to attach manually in SAP.

 

Thanks!


Viewing all articles
Browse latest Browse all 325

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>