Question

I have written a code to take screen shots whenever webpage navigates and paste it in Word document using VBA, I succeeded in doing that but I am getting the screen shots that took last time instead of present one.

Example whenever I press printscreen it is pasting screen shot took last time instead of present one. I tried doing delays and making the argument to true, false nothing worked.

This is what I have tried in Class1 module:

Option Explicit
Dim WithEvents ie As InternetExplorer
Dim wordapp As Object
Dim wrdDoc As Object
Dim t As Date
Sub Example()
Set wordapp = CreateObject("word.Application")

wordapp.Visible = True
Set wrdDoc = wordapp.Documents.Add
Set ie = New InternetExplorer
ie.navigate "http://www.csee.wvu.edu/~riggs/html/select_example.html"
Do Until ie.readyState = READYSTATE_COMPLETE: DoEvents: Loop
test
End Sub
Private Function href_onclick() As Boolean

Application.SendKeys "{44}"
wordapp.Selection.Paste
End Function

in a module

Sub initialise()
Set ev = New Class1
ev.Example

End Sub
Was it helpful?

Solution 2

After all struggling i came up with this solution, I just made the paste option to wait for 3 secs till the picture gets loaded into the clipboard ....:)sendkeys with true option doesn't work at all.

OTHER TIPS

try Application.SendKeys "{44}", True

The Second parameter tells the execution of the code to wait for the action to complete

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top