I have created a macro/userform that creates an html file and want Internet Explorer 11 to show the page.
When you use the userform you create new data that should be shown on the page. How do I refresh the page on IE11?
I tried using meta refresh, but if the userform writes the page at the moment IE refreshes the page goes blank and stops from refreshing.
Another method I tried is sendkeys but it doesn't seem to work.
AppActivate "The page - Internet Explorer"
SendKeys "{F5}", True
nothing happens.
Are there any other options to make sure the page is refreshed and always visible? (meaning don't refresh when the file is in use by the userform)
If page is already opened then you need to find that specific page and then you can try to refresh it. you can try to find the page by its title.
See the example code below.
Sub demo1()
flag = 0
Set objShell = CreateObject("Shell.Application")
IE_count = objShell.Windows.Count
For x = 0 To (IE_count - 1)
On Error Resume Next
my_url = objShell.Windows(x).Document.Location
my_title = objShell.Windows(x).Document.Title
If my_title Like "Microsoft" & "*" Then
Set ie = objShell.Windows(x)
ie.Refresh
flag = 1
Exit For
Else
End If
Next
If flag = 0 Then
Debug.Print ("A matching webpage was NOT found")
Else
Debug.Print ("A matching webpage was found")
End If
End Sub
Try to modify the title in code to match with your web page.