Control Internet Explorer from VBA
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)
vba refresh internet-explorer-11
add a comment |
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)
vba refresh internet-explorer-11
add a comment |
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)
vba refresh internet-explorer-11
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)
vba refresh internet-explorer-11
vba refresh internet-explorer-11
edited Nov 19 '18 at 10:10
QHarr
31.1k81941
31.1k81941
asked Nov 19 '18 at 9:51
AndreasAndreas
15.3k31542
15.3k31542
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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 SubTry to modify the title in code to match with your web page.
Thank you for the suggestion. But this code only creates a new window, It doesn't control an already open window. My code creates/changes the html in a text file and a browser needs to display it on a screen not viewable by the user. That is why I don't want new windows or a meta refresh since it can get stuck in the middle.
– Andreas
Nov 20 '18 at 7:49
@ Andreas, Please check the modified answer may help you to solve your issue.
– Deepak-MSFT
Nov 20 '18 at 9:47
That looks interesting! I will have a look at it soon. IsIf my_title Like "Microsoft" & "*" Thenthat I need to change to make it find the correct widow?*should be replaced withmy pageif the title of the page ismy page?
– Andreas
Nov 20 '18 at 9:51
1
* is for wild card characters. You can just add the title at the place of 'Microsoft'. Leave the * as it is. Note that it is case sensitive.
– Deepak-MSFT
Nov 20 '18 at 10:03
Got it working! I needed to change the line as I expected. But toIf my_title Like "My page" & "*" Then
– Andreas
Nov 20 '18 at 10:30
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372041%2fcontrol-internet-explorer-from-vba%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 SubTry to modify the title in code to match with your web page.
Thank you for the suggestion. But this code only creates a new window, It doesn't control an already open window. My code creates/changes the html in a text file and a browser needs to display it on a screen not viewable by the user. That is why I don't want new windows or a meta refresh since it can get stuck in the middle.
– Andreas
Nov 20 '18 at 7:49
@ Andreas, Please check the modified answer may help you to solve your issue.
– Deepak-MSFT
Nov 20 '18 at 9:47
That looks interesting! I will have a look at it soon. IsIf my_title Like "Microsoft" & "*" Thenthat I need to change to make it find the correct widow?*should be replaced withmy pageif the title of the page ismy page?
– Andreas
Nov 20 '18 at 9:51
1
* is for wild card characters. You can just add the title at the place of 'Microsoft'. Leave the * as it is. Note that it is case sensitive.
– Deepak-MSFT
Nov 20 '18 at 10:03
Got it working! I needed to change the line as I expected. But toIf my_title Like "My page" & "*" Then
– Andreas
Nov 20 '18 at 10:30
add a comment |
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 SubTry to modify the title in code to match with your web page.
Thank you for the suggestion. But this code only creates a new window, It doesn't control an already open window. My code creates/changes the html in a text file and a browser needs to display it on a screen not viewable by the user. That is why I don't want new windows or a meta refresh since it can get stuck in the middle.
– Andreas
Nov 20 '18 at 7:49
@ Andreas, Please check the modified answer may help you to solve your issue.
– Deepak-MSFT
Nov 20 '18 at 9:47
That looks interesting! I will have a look at it soon. IsIf my_title Like "Microsoft" & "*" Thenthat I need to change to make it find the correct widow?*should be replaced withmy pageif the title of the page ismy page?
– Andreas
Nov 20 '18 at 9:51
1
* is for wild card characters. You can just add the title at the place of 'Microsoft'. Leave the * as it is. Note that it is case sensitive.
– Deepak-MSFT
Nov 20 '18 at 10:03
Got it working! I needed to change the line as I expected. But toIf my_title Like "My page" & "*" Then
– Andreas
Nov 20 '18 at 10:30
add a comment |
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 SubTry to modify the title in code to match with your web page.
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 SubTry to modify the title in code to match with your web page.
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 SubSub 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 Subedited Nov 20 '18 at 9:47
answered Nov 20 '18 at 2:32
Deepak-MSFTDeepak-MSFT
647116
647116
Thank you for the suggestion. But this code only creates a new window, It doesn't control an already open window. My code creates/changes the html in a text file and a browser needs to display it on a screen not viewable by the user. That is why I don't want new windows or a meta refresh since it can get stuck in the middle.
– Andreas
Nov 20 '18 at 7:49
@ Andreas, Please check the modified answer may help you to solve your issue.
– Deepak-MSFT
Nov 20 '18 at 9:47
That looks interesting! I will have a look at it soon. IsIf my_title Like "Microsoft" & "*" Thenthat I need to change to make it find the correct widow?*should be replaced withmy pageif the title of the page ismy page?
– Andreas
Nov 20 '18 at 9:51
1
* is for wild card characters. You can just add the title at the place of 'Microsoft'. Leave the * as it is. Note that it is case sensitive.
– Deepak-MSFT
Nov 20 '18 at 10:03
Got it working! I needed to change the line as I expected. But toIf my_title Like "My page" & "*" Then
– Andreas
Nov 20 '18 at 10:30
add a comment |
Thank you for the suggestion. But this code only creates a new window, It doesn't control an already open window. My code creates/changes the html in a text file and a browser needs to display it on a screen not viewable by the user. That is why I don't want new windows or a meta refresh since it can get stuck in the middle.
– Andreas
Nov 20 '18 at 7:49
@ Andreas, Please check the modified answer may help you to solve your issue.
– Deepak-MSFT
Nov 20 '18 at 9:47
That looks interesting! I will have a look at it soon. IsIf my_title Like "Microsoft" & "*" Thenthat I need to change to make it find the correct widow?*should be replaced withmy pageif the title of the page ismy page?
– Andreas
Nov 20 '18 at 9:51
1
* is for wild card characters. You can just add the title at the place of 'Microsoft'. Leave the * as it is. Note that it is case sensitive.
– Deepak-MSFT
Nov 20 '18 at 10:03
Got it working! I needed to change the line as I expected. But toIf my_title Like "My page" & "*" Then
– Andreas
Nov 20 '18 at 10:30
Thank you for the suggestion. But this code only creates a new window, It doesn't control an already open window. My code creates/changes the html in a text file and a browser needs to display it on a screen not viewable by the user. That is why I don't want new windows or a meta refresh since it can get stuck in the middle.
– Andreas
Nov 20 '18 at 7:49
Thank you for the suggestion. But this code only creates a new window, It doesn't control an already open window. My code creates/changes the html in a text file and a browser needs to display it on a screen not viewable by the user. That is why I don't want new windows or a meta refresh since it can get stuck in the middle.
– Andreas
Nov 20 '18 at 7:49
@ Andreas, Please check the modified answer may help you to solve your issue.
– Deepak-MSFT
Nov 20 '18 at 9:47
@ Andreas, Please check the modified answer may help you to solve your issue.
– Deepak-MSFT
Nov 20 '18 at 9:47
That looks interesting! I will have a look at it soon. Is
If my_title Like "Microsoft" & "*" Then that I need to change to make it find the correct widow? * should be replaced with my page if the title of the page is my page?– Andreas
Nov 20 '18 at 9:51
That looks interesting! I will have a look at it soon. Is
If my_title Like "Microsoft" & "*" Then that I need to change to make it find the correct widow? * should be replaced with my page if the title of the page is my page?– Andreas
Nov 20 '18 at 9:51
1
1
* is for wild card characters. You can just add the title at the place of 'Microsoft'. Leave the * as it is. Note that it is case sensitive.
– Deepak-MSFT
Nov 20 '18 at 10:03
* is for wild card characters. You can just add the title at the place of 'Microsoft'. Leave the * as it is. Note that it is case sensitive.
– Deepak-MSFT
Nov 20 '18 at 10:03
Got it working! I needed to change the line as I expected. But to
If my_title Like "My page" & "*" Then– Andreas
Nov 20 '18 at 10:30
Got it working! I needed to change the line as I expected. But to
If my_title Like "My page" & "*" Then– Andreas
Nov 20 '18 at 10:30
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372041%2fcontrol-internet-explorer-from-vba%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown