Hi All,
I have returned to above subject few days ago. Please see my solution for attaching emails directly from Outlook to SAP
If anyone is interested please see the VBA code I used in Outlook 2007 (vba saves email as msg on Z:\Test, copy the file path to clipboard then open SAP, FB03 input data from textboxes. Enters the document, opens create attachment window and then STOP
1) code which opens userform
Sub RunAttacher()
JVForm.Show
End Sub
2) JVForm has 3 text fields where you should put document no., fiscal year and company code. The same as in FB03. After clicking "proceed"
macro starts.
Private Sub CommandButton1_Click()
Dim Original As Outlook.MailItem
Dim subject As String
Dim MyText As DataObject, TextStr As String
Dim spath As String
Set MyText = New DataObject
'Kill ("Z:\test\*.*")
Set Original = Application.ActiveExplorer.Selection(1)
Original.SaveAs "Z:\TEST\" & TextBox1.Text & ".msg", o1msg
spath = "Z:\TEST\" & TextBox1.Text & ".msg"
MyText.SetText spath
MyText.PutInClipboard
If Not IsObject(Wantuch) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Wantuch = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = Wantuch.Children(0)
End If
If Not IsObject(Session1) Then
Set Session1 = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject Session, "on"
WScript.ConnectObject Wantuch, "on"
End If
Session1.findById("wnd[0]").maximize
Session1.findById("wnd[0]/tbar[0]/okcd").Text = "/nfb03"
Session1.findById("wnd[0]").sendVKey 0
Session1.findById("wnd[0]/usr/txtRF05L-BELNR").Text = TextBox1.Text
Session1.findById("wnd[0]/usr/ctxtRF05L-BUKRS").Text = TextBox2.Text
Session1.findById("wnd[0]/usr/txtRF05L-GJAHR").Text = TextBox3.Text
Session1.findById("wnd[0]/usr/txtRF05L-GJAHR").SetFocus
Session1.findById("wnd[0]/usr/txtRF05L-GJAHR").caretPosition = 4
Session1.findById("wnd[0]").sendVKey 0
Session1.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"
Session1.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_PCATTA_CREA"
Unload Me
End Sub
Now user activates SAP FB03 session and pastes the path by CTRL + V
Unfortunatelly I don't know other solution for pasting the path where email is saved. I can't control explorer window (nothing works here

, sendkeys, autohotkey..) If anyone knows the solution how to control the explorer window from VBA then kindly share

Thanks
Greg