[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Manipulating Internet Explorer through Excel's VBA

Asked by jss56 in VB Script, Visual Basic v1.0.5.x, Microsoft Office Suite

Tags: VBA, internet explorer, excel, vbscript, vb, visual basic

Hi, I have a macro in Excel that opens up two instances of Google Maps and takes a few parameters from a spreadsheet to look up addresses on Google Maps. I wrote the code in VBScript earlier, and now that I am using it in VBA it doesn't work quite the way I want.

One issue is that instead of opening up new instances of Internet Explorer to navigate to Google maps, it instead opens up a new tab in my preexisting Internet explorer window and navigates to google maps.

The second more important issue is that in the GoogleLookup() sub routine, the code reaches "Set wshShell = wscript.CreateObject("WScript.Shell")" and then exits the sub routine, ignoring all of the rest of the code in that routine.

Any help is greatly appreciated. Thanks!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
Sub AddressLookup()
 
On Error Resume Next
 
Set objWShell = CreateObject("Wscript.Shell")
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
Set IE1 = objShellWindows.Item
Set IE2 = objShellWindows.Item
Set IE3 = objShellWindows.Item
 
Dim currentCell As String
Dim primAddr1 As String
Dim secAddr1 As String
Dim primAddr2 As String
Dim secAddr2 As String
Dim city1 As String
Dim city2 As String
Dim state1 As String
Dim state2 As String
Dim zip1 As String
Dim zip2 As String
'Dim strLine
 
'Const ForReading = 1
'Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set objTextFile = objFSO.OpenTextFile("address.txt", ForReading)
'strLine = add1
'Address1 = Split(strLine, ",")
 
currentCell = ActiveCell.Address
primAddr1 = ActiveCell.Offset(0, -15).Value
primAddr2 = ActiveCell.Offset(0, -14).Value
secAddr1 = ActiveCell.Offset(0, -12).Value
secAddr2 = ActiveCell.Offset(0, -11).Value
city1 = ActiveCell.Offset(0, -9).Value
city2 = ActiveCell.Offset(0, -8).Value
state1 = ActiveCell.Offset(0, -6).Value
state2 = ActiveCell.Offset(0, -5).Value
zip1 = ActiveCell.Offset(0, -3).Value
zip2 = ActiveCell.Offset(0, -2).Value
 
 
URL1 = "http://maps.google.com/"
URL2 = "http://maps.google.com/"
 
 
IE2.Navigate2 URL2
If Err.Number <> 0 Then
 Set IE2 = wscript.CreateObject("InternetExplorer.Application")
 IE2.Visible = True
 IE2.Navigate2 URL2
 IE2.Height = 432
 IE2.Width = 575
 IE2.Left = 575
 IE2.Top = 0
End If
 
 
IE1.Navigate2 URL1
If Err.Number <> 0 Then
 Do While IE2.Busy
 Loop
 Set IE1 = wscript.CreateObject("InternetExplorer.Application")
 IE1.Visible = True
 IE1.Navigate2 URL1
 IE1.Height = 432
 IE1.Width = 575
 IE1.Left = 0
 IE1.Top = 0
End If
 
 
GoogleLookup (IE1)
 
 
Set IE1 = Nothing
Set IE2 = Nothing
Set objShellWindows = Nothing
Set objShell = Nothing
 
End Sub
 
 
Private Sub GoogleLookup(ie)
 
Dim wshShell
Set wshShell = wscript.CreateObject("WScript.Shell")
 
wshShell.AppActivate ("Google Maps") 'Title of the window...
wscript.sleep (100)
 
wshShell.SendKeys "{TAB}"
wshShell.SendKeys "{TAB}"
wshShell.SendKeys "{TAB}"
wshShell.SendKeys "{TAB}"
wshShell.SendKeys "{TAB}"
wshShell.SendKeys "{TAB}"
wshShell.SendKeys "{TAB}"
wshShell.SendKeys "{TAB}"
ie.Document.All.Item("q").Value = primAddr1 & "," & secAddr1 & "," & city1 & "," & state1 & "," & zip1
wshShell.SendKeys "{ENTER}"
 
End Sub
[+][-]09/08/09 04:31 PM, ID: 25287080Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: VB Script, Visual Basic v1.0.5.x, Microsoft Office Suite
Tags: VBA, internet explorer, excel, vbscript, vb, visual basic
Sign Up Now!
Solution Provided By: brettdj
Participating Experts: 1
Solution Grade: A
 
[+][-]09/09/09 05:13 AM, ID: 25290300Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/09/09 07:01 AM, ID: 25291364Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625