I am trying to take a screenshot, paste it into a new Word document, then save in local area.
Below functions are working:
- Create new Word document and save.
- Take screen shot.
Issues:
- It is taking the screen shot after creating, saving and closing the Word document.
- It pastes that screen shot in Excel after executing this code.
- It is not pasting that screen shot in the Word document.
I have tried unsuccesfully to paste the screen shot in the Word document with
wshShell.SendKeys "^v"
wshShell.Selection.Paste
Expectation:
- Take a screnshot before creating the Word document.
- Automatically paste in the Word document and save.
.
Set wshShell = CreateObject("WSCript.shell")
Sleep 2000
keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
Sleep 35000
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Sleep 5000
wshShell.SendKeys "^{v}"
wshShell.SendKeys "~"
Sleep 5000
objDoc.SaveAs ("D:\Srene\sample.docx")
objWord.Quit
Try wait = true
SendKeys string[, wait]
Wait: Optional. Boolean value specifying the wait mode. If False (default), control is returned to the procedure immediately after the keys are sent. If True, keystrokes must be processed before control is returned to the procedure.
http://msdn.microsoft.com/en-us/library/gg278655(v=office.14).aspx