Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

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

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 22
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

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 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.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

610 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