Solved

Access VBA to open list of websites in the text box in their independent windows.

Posted on 2016-09-19
7
38 Views
Last Modified: 2016-09-25
I have a list of 5 to 10 websites that I want to open from access with a button. I was trying to use a list box, but I think using a textbox will be better. for example, this is how it would look...

Google.com
Bing.com
Yahoo.com
CNN.com
Apple.com
Fox.com
expert-exchange.com
____________________________

button goes here "open sites"


So basically it needs to loop through the list and open each site independently. The list will grow or shrink too.

Thank you for all the help.
0
Comment
Question by:toalexsandr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 37

Expert Comment

by:PatHartman
ID: 41805515
A text box won't be better.  You'd have to store the whole list as a string.  If the list varies, use a table and display it as a subform if you want to allow edits or with a listbox if you don't.

Create a loop to read a recordset, NOT the listbox or subform.  Use the FollowHyperlink method to open the sites.  That will open each site in turn in your default browser.
0
 
LVL 20
ID: 41805538
In addition to putting the sites into a tablle, you might take it one step further and use Application.FollowHyperlink  to open them to the search term you are looking for.  Each site may have differences in how it encodes a search in the URL -- search on each site and look. Be sure to include this in the table too

google uses
https://www.google.com/#q=MyWord

Bing uses
http://www.bing.com/search?q=Myword

looking for "My Phrase" on bing is
http://www.bing.com/search?q="My+Phrase"

sometimes you will see:

%20 = space
%22 = double quote mark
0
 

Author Comment

by:toalexsandr
ID: 41805798
I understand what you mean.  What about parsing a string based on either a return character or an empty space, or a comma? Can this approach be used or its not practical?
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Accepted Solution

by:
toalexsandr earned 0 total points
ID: 41806687
I have figured it out. Here is the code to open sites from Access form using VBA. Unfortunately they open in separate windows, but this is good enough for me. Later I will bound it to a table field so that it will be stored in the database.
Private Sub cmdOpenURLs_Click()

   Dim strTest As String
   Dim strArray() As String
   Dim intCount As Integer
   Dim objIE As Object
    strTest = Me.txtOpenURLs
    strArray = Split(strTest, Chr(13))
For intCount = LBound(strArray) To UBound(strArray)
    Set objIE = New InternetExplorer
    objIE.Top = 0
    objIE.Left = 0
    objIE.Width = 1200
    objIE.Height = 900
    objIE.Visible = True
    objIE.Navigate ("http://" & strArray(intCount))
    Do
    DoEvents
    Loop Until objIE.ReadyState = 4
Next
    Set objIE = Nothing  
End Sub

Open in new window


URL List
I got the split function from Microsoft website and modified it a little. Split Function
0
 
LVL 20
ID: 41806845
if you want pages in the same window, you can drag Tabs once they are open
0
 
LVL 37

Expert Comment

by:PatHartman
ID: 41806912
They open in separate windows because that is what you asked them to do.

Set objIE = New InternetExplorer

The FollowHyperlink method will use an existing instance of the default browser and add tabs.
0
 

Author Closing Comment

by:toalexsandr
ID: 41814579
Works perfectly for what I needed it.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question