+ Reply to Thread
Results 1 to 8 of 8

Navigate to a webpage and exit if webpage redirects

  1. #1
    Forum Contributor
    Join Date
    11-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    334

    Navigate to a webpage and exit if webpage redirects

    I am opening webpages from URL's in a worksheet so that I can print the specific webpage:

    Please Login or Register  to view this content.
    Occasionally the URL does not exist and redirects to the home page.
    I would like to exit my code if the webpage redirects.

    Any advice on how I could achieve this?

  2. #2
    Forum Guru
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,122

    Re: Navigate to a webpage and exit if webpage redirects

    These codes are mine, but you can adjust them to your needs.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    334

    Re: Navigate to a webpage and exit if webpage redirects

    Thanks AB33, will give it a try!

  4. #4
    Forum Contributor
    Join Date
    11-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    334

    Re: Navigate to a webpage and exit if webpage redirects

    AB33,

    Your code doesn't do what I need.
    If my original URL gets redirected then the result is "URL FOUND".
    If my original URL gets redirected I want to exit the code before it executes the next step (print).

    Any other ideas?

  5. #5
    Forum Guru
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,122

    Re: Navigate to a webpage and exit if webpage redirects

    I have not even read your request in detail. Where is your full code and what do you want to change?

  6. #6
    Forum Contributor
    Join Date
    11-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    334

    Re: Navigate to a webpage and exit if webpage redirects

    This takes the URL from each range:

    Please Login or Register  to view this content.
    This opens IE and navigates to the URL
    Please Login or Register  to view this content.
    The rest of my code is not relevant to the problem. It simply executes the printing of the webpage.

    What I want to do is this:

    If the URL that opens here:
    Please Login or Register  to view this content.
    Isn't the same as the one here: (i.e. pageURL gets redirected because it doesn't exist):

    Please Login or Register  to view this content.
    Then I don't want want the webpage to print, I want to exit the code.
    Last edited by anrichards22; 06-28-2016 at 12:17 AM.

  7. #7
    Forum Guru
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,122

    Re: Navigate to a webpage and exit if webpage redirects

    It is difficult to understand your request with out looking at the entire code. For example, what is pageURL? I do not see it in any part of code.

  8. #8
    Forum Contributor
    Join Date
    11-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    334

    Re: Navigate to a webpage and exit if webpage redirects

    PageURL is the URL variable.

    The solution turned out to be very simple.
    Thanks for your assistance.

    Solution:
    After IE opens the webpage, test to see if the URL is the same as the URL from the worksheet range, like this:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help with getting data from webpage
    By simmo1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-14-2013, 01:07 PM
  2. Vba code for using webpage ( Tracking Goods c/ment on webpage)
    By satputenandkumar0 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-30-2013, 06:03 AM
  3. [SOLVED] Load webpage on TOPMAN website, extract prices from webpage into Spreadsheet
    By AKK9 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-04-2013, 11:49 AM
  4. Macro to Open webpage, then save webpage as txt file.
    By jasocke2 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-07-2012, 04:25 AM
  5. Workbook to Webpage
    By phoztek in forum Excel General
    Replies: 0
    Last Post: 07-08-2011, 08:02 AM
  6. Opening a webpage with VBA
    By wilro85 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-24-2008, 07:58 PM
  7. Webpage
    By EMoorhead in forum Excel General
    Replies: 2
    Last Post: 02-26-2006, 11:00 AM
  8. [SOLVED] save as webpage?
    By in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-15-2005, 05:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1