Hi Script Man,
I am having a similar issue to export to MHTML using SAP Scripting. I created a macro that open SAP GUI and do the required transaction. However, I got stuck exporting to MHTML. The code must save as MHTML in the path described below and then open the "export.MHTLM" file.
This is the code I have until now:
Sub SAPScripting_exportMHTML()
Set app = CreateObject("Sapgui.ScriptingCtrl.1")
Set Connection = app.OpenConnection("# E05 - R/3 - Produção", True)
Set Session = Connection.Children(0)
'Code to login on SAP GUI and do desired transaction:
Session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "C2MARCOSEC"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "*******"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").SetFocus
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 8
Session.findById("wnd[0]").sendVKey 0
Session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selecedNode = "F00003"
Session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00003"
Session.findById("wnd[0]/tbar[1]/btn[8]").press
Session.findById("wnd[0]/tbar[1]/btn[17]").press
Session.findById("wnd[1]/tbar[0]/btn[8]").press
Session.findById("wnd[0]/tbar[1]/btn[8]").press
'This is where I try to export to MHTML:
Path = "D:\Users\est.marcosec\Desktop\Marcos\SAP - Script\export.MHTML" 'The "export.MHTML" file already exists
Set Wshell = CreateObject("WScript.Shell")
Wshell.Run """D:\Users\est.marcosec\Desktop\Marcos\SAP - Script\save_as.vbs """ & Path
Session.findById("wnd[0]/tbar[1]/btn[16]").press
End Sub
It would be great to get this code done. I send several reports everyday. This will save a lot of time.
Best Regards,
Marcos Eickhoff Cortopassi