on 10-07-2014 9:02 PM
Dear Experts,
I have been trying to access the clipboard for screenshot of SAP copied through "session.findById("wnd[0]").HardcopyToMemory" and pasting the same in an Excel Sheet.
I have been trying the same for last two weeks unsuccessfully.
Requesting for your Kind help if someone have already addressed this issue.
Please let me know if i have to furnish some more details..
Regards,
Kumar Santharam
Hello.
Shortest way is copy Picture as file and insert into Excel from file. After this is done delete created file.
With some smart code using shapes you can Position Pictures on sheet.
Sub image_sap()
If Not IsObject(Applic) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Applic = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = Applic.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
session.findById("wnd[0]").HardCopy "C:\tmp\test.jpg", 1
ActiveWorkbook.ActiveSheet.Pictures.Insert "C:\tmp\test.jpg"
Kill "C:\tmp\test.jpg"
End Sub
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello. In SAP Scripting Help file (CHM) you can find this Piece of code:
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
Image = session.findById("wnd[0]").HardCopyToMemory()
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = adTypeBinary
BinaryStream.Open
BinaryStream.Write Image
BinaryStream.SaveToFile "C:\screenshot.bmp", adSaveCreateOverWrite
MsgBox "Done"
With some API-functions you should also be able to read Image from Memory and paste in Excel sheet. But first Piece of code is much smaller.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.