?
Solved

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

Posted on 2016-09-19
7
Medium Priority
?
40 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 38

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 21
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 21
ID: 41806845
if you want pages in the same window, you can drag Tabs once they are open
0
 
LVL 38

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

743 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