Here's what I'm trying to do. I have published an internet map site on our intranet where local users can create their own custom maps.
I want to create a button on that webpage (using a combination VB and ASP) that when clicked will take a snap shot of the active window (the map they have created) and paste it to their clipboard. Then I want to launch PowerPoint on their workstation, add a blank slide, and paste the snap shot from their clipboard onto that blank slide.
Is this possible? I have some code, but I would like someone with more VB experience than me to check it out. I have tested it on my computer by sticking the code behind a command button on a user form in MS Word, and it runs fine up until the last 3 or 4 lines of code (the paste from clipboard part). I get a run-time error '424': object required error on the line: Set Picture = Clipboard.GetData(vbCFBitmap).
Any advice? Here is the code:
VB Code:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const VK_SNAPSHOT = &H2C
' Get the Active Window
keybd_event vbKeySnapshot, 1, 0, 0
Dim ppApp
Set ppApp = CreateObject("Powerpoint.Application")
This line is generating an error because the clipboard object
is trying to be set to the Picture object (Defined as ???). You can't use the
clipboard object this way. You need to define a IPictureDisp
object to hold the clipboard data, add that as the picture.
VB Code:
Dim iPic As IPictureDisp
Set iPic = Clipboard.GetData(vbCFBitmap)
ppSlide1.Shapes.AddPicture (iPic)
If you right click the vbforums logo picture and click Copy, and run
this code below, it will paste the vb image on to the form.
VB Code:
Option Explicit
Private Sub Form_Load()
Dim iPic As IPictureDisp
Set iPic = Clipboard.GetData(vbCFBitmap)
Form1.Picture = iPic
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Yes, your code works, but when I modify it to fit my app something is causing it not to paste the snapshot into PowerPoint. Can you try my code from the post dated 09-16-2004 11:25 AM? I just want a snapshot of the active screen to be pasted on a blank slide in PwerPoint.
I've been putting it behing a Command Button (CommandButton1) on a User Form in MS Word to test it. Maybe you'll get a better idea of what I'm trying to do, and see the error I'm getting if you try that.
I can click the paste button to drop the image from the clipboard once PowerPoint opens, but that's not what I want the user to have to do.