QuietRiot
07-06-2007, 05:51 PM
I have this code in excel. What it does is it minimizes the excel window takes a print screen of whatever is behind it then brings up word pastes it in word then brings the excel window to normal.
But, I need/want it to save the word doc as the string (saveit) and then close without asking anything.
any help
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const VK_SNAPSHOT = &H2C
Sub PrintScreen2Word()
Application.ScreenUpdating = False
Dim saveit As String
saveit = "thisisatest"
'Minimize Excel
Application.WindowState = xlMinimized
'Wait 2 seconds to allow time for the minimization
Sleep (2000)
'Take Screen Shot
keybd_event VK_SNAPSHOT, 0, 0, 0
'Open a new Word document
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add
'Paste
wrdApp.Selection.Paste
'some error checkin
Set wrdDoc = Nothing
Set wrdApp = Nothing
Application.WindowState = xlNormal
Application.ScreenUpdating = True
End Sub
file:///C:/DOCUME%7E1/COMPUT%7E1/LOCALS%7E1/Temp/moz-screenshot.jpg
But, I need/want it to save the word doc as the string (saveit) and then close without asking anything.
any help
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const VK_SNAPSHOT = &H2C
Sub PrintScreen2Word()
Application.ScreenUpdating = False
Dim saveit As String
saveit = "thisisatest"
'Minimize Excel
Application.WindowState = xlMinimized
'Wait 2 seconds to allow time for the minimization
Sleep (2000)
'Take Screen Shot
keybd_event VK_SNAPSHOT, 0, 0, 0
'Open a new Word document
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add
'Paste
wrdApp.Selection.Paste
'some error checkin
Set wrdDoc = Nothing
Set wrdApp = Nothing
Application.WindowState = xlNormal
Application.ScreenUpdating = True
End Sub
file:///C:/DOCUME%7E1/COMPUT%7E1/LOCALS%7E1/Temp/moz-screenshot.jpg