montrealraaj
01-27-2010, 10:49 AM
Hi All,
First, I would like to thank all the contributors in the forum.
I am a newbie for VBA and I learnt a lot of tricks from the posts in this forum.
Curretly I am working on a small VBA program by which I can printscreen paste the same in word and crop the pasted picture to desired size.
I got the code working till pasting the printscreen in word.
Now editing the picture with Picture format seems to be a undoable task.
Nothing seems to work....So Somebody please help :help
Option Explicit
Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function EmptyClipboard Lib "user32" () As Long
Public Declare Function CloseClipboard Lib "user32" () As Long
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
Sub PrintScreen()
keybd_event VK_SNAPSHOT, 6, 0, 0
End Sub
Sub PCPCR()
Call PrintScreen
Selection.PasteSpecial Placement:=wdInLine
Selection.Collapse Direction:=wdCollapseEnd
End Sub
It works till this point and when I type the following It throws an error
Compiler Error :Method or Data Member not found and .PictureFormat is selected.
Selection.InlineShapes.PictureFormat.CropRight =248
Then I tried pasting the selection as shape and added the following i/o existing PasteSpeacial Statement
Selection.PasteSpecial Placement:=wdInLine, DataType:=wdPasteShape
and I get the following error.
"Runtime Error:5342
The specified DataType is unavailable"
I donno as what i am doing wrong so somebody please help me : pray2:
Thanks in advance for your time and Help.
Regards
Montrealraaj.
First, I would like to thank all the contributors in the forum.
I am a newbie for VBA and I learnt a lot of tricks from the posts in this forum.
Curretly I am working on a small VBA program by which I can printscreen paste the same in word and crop the pasted picture to desired size.
I got the code working till pasting the printscreen in word.
Now editing the picture with Picture format seems to be a undoable task.
Nothing seems to work....So Somebody please help :help
Option Explicit
Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function EmptyClipboard Lib "user32" () As Long
Public Declare Function CloseClipboard Lib "user32" () As Long
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
Sub PrintScreen()
keybd_event VK_SNAPSHOT, 6, 0, 0
End Sub
Sub PCPCR()
Call PrintScreen
Selection.PasteSpecial Placement:=wdInLine
Selection.Collapse Direction:=wdCollapseEnd
End Sub
It works till this point and when I type the following It throws an error
Compiler Error :Method or Data Member not found and .PictureFormat is selected.
Selection.InlineShapes.PictureFormat.CropRight =248
Then I tried pasting the selection as shape and added the following i/o existing PasteSpeacial Statement
Selection.PasteSpecial Placement:=wdInLine, DataType:=wdPasteShape
and I get the following error.
"Runtime Error:5342
The specified DataType is unavailable"
I donno as what i am doing wrong so somebody please help me : pray2:
Thanks in advance for your time and Help.
Regards
Montrealraaj.