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
Solved

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

Posted on 2016-09-19
7
34 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 35

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 19
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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

809 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