Control Internet Explorer from VBA












-1















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)










share|improve this question





























    -1















    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)










    share|improve this question



























      -1












      -1








      -1








      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)










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '18 at 10:10









      QHarr

      31.1k81941




      31.1k81941










      asked Nov 19 '18 at 9:51









      AndreasAndreas

      15.3k31542




      15.3k31542
























          1 Answer
          1






          active

          oldest

          votes


















          1














          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.






          share|improve this answer


























          • 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. 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





            * 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











          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          1














          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.






          share|improve this answer


























          • 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. 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





            * 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
















          1














          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.






          share|improve this answer


























          • 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. 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





            * 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














          1












          1








          1







          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.






          share|improve this answer















          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.






          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





          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






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 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. 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





            * 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



















          • 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. 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





            * 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

















          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


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          How to send String Array data to Server using php in android

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Is anime1.com a legal site for watching anime?