Attachmate -> IE -> Attachmate
Attachmate -> IE -> Attachmate
(OP)
I currently have a macro that runs some commands in a session then opens internet explorer, performs a search from that page, and now i want to get it to go back to the session it was started in and continue to run.
1. Start in Attachmate Session
2. Pull Data
3. Open Internet Explorer to a search page
4. Use data pulled from Attachmate to perform search
(No data pulled from Internet)
6. Return to original Session
7. Prompt a dialog box for user input
I can run steps 1-4 on their own but I need help on the code required to return to the original session. Please assist!
1. Start in Attachmate Session
2. Pull Data
3. Open Internet Explorer to a search page
4. Use data pulled from Attachmate to perform search
(No data pulled from Internet)
6. Return to original Session
7. Prompt a dialog box for user input
I can run steps 1-4 on their own but I need help on the code required to return to the original session. Please assist!
RE: Attachmate -> IE -> Attachmate
'Dialogbox/Inputbox for user search
Do While UserSearch <> ""
'Your code for steps 1-4...
Session.Activate
'Call Dialogbox/Inputbox again
Loop
RE: Attachmate -> IE -> Attachmate
Declare Sub Wait(objIE As Object)
Sub Main()
Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object, objIE As Object, i as Integer
<Attachmate Commands...>
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Visible = True
.Navigate "internal website address"
End With
Call Wait(objIE)
objIE.Document.All("txtcovcode").Value = covcd
objIE.Document.All("txtgroupnum").Value = grpnum
objIE.Document.All("txtgroupbu").Value = bu
objIE.Document.All("btnsearchnow").Click
Call Wait(objIE)
End Sub
Private Sub Wait(objIE As Object)
While objIE.Busy
DoEvents
Wend
While objIE.Document.ReadyState <> "complete"
DoEvents
Wend
Sess1.Activate
I am getting a CALL syntax error on the Sess1.Activate command.
RE: Attachmate -> IE -> Attachmate
CODE
With objIE
.Visible = True
.Navigate "internal website address"
Call Wait(objIE)
.Document.All("txtcovcode").Value = covcd
.Document.All("txtgroupnum").Value = grpnum
.Document.All("txtgroupbu").Value = bu
.Document.All("btnsearchnow").Click
Call Wait(objIE)
End With
'The following will make the session the active window
Sess.Activate
'Prompting for info
sUserInput = InputBox("Prompting for user input...","Need Input")
If you need something more complicated than an InputBox you can create a dialogbox to obtain the info. There are quite a few threads in this forum covering dialogboxes.
RE: Attachmate -> IE -> Attachmate
Using your code I get a 'Unknown Function: Wait' error.
Do I not need the following in the code? I used this from one of the other threads.
Declare Sub Wait(objIE As Object)
Private Sub Wait(objIE As Object)
While objIE.Busy
DoEvents
Wend
While objIE.Document.ReadyState <> "complete"
DoEvents
Wend
RE: Attachmate -> IE -> Attachmate
CODE
RE: Attachmate -> IE -> Attachmate
CODE
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Visible = True
.Navigate "internal website address"
End With
Call Wait(objIE)
objIE.Document.All("txtcovcode").Value = covcd
objIE.Document.All("txtgroupnum").Value = grpnum
objIE.Document.All("txtgroupbu").Value = bu
objIE.Document.All("btnsearchnow").Click
Call Wait(objIE)
Oh, and it looks like I missed this line...
Set objIE = CreateObject("InternetExplorer.Application")
So put it back in before the With objIE line.
You can use AppActivate, but Sess.Activate is going to be more accurate.
RE: Attachmate -> IE -> Attachmate
This is what I have now
Declare Sub Wait(objIE As Object)
Sub Main()
<attachmate commands...>
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Visible = True
.Navigate "internal site"
Call Wait(objIE)
objIE.Document.All("txtcovcode").Value = covcod
objIE.Document.All("txtgroupnum").Value = grpnum
objIE.Document.All("txtgroupbu").Value = bu
objIE.Document.All("btnsearchnow").Click
Call Wait(objIE)
Private Sub Wait(objIE As Object)
While objIE.Busy
DoEvents
Wend
While objIE.Document.ReadyState <> "complete"
DoEvents
Wend
End With
Sess.Activate
<remaing attachmate commands...>
I am getting an 'Illegal Statement' on the "Private Sub Wait(objIE As Object)" command.
Thanks to everyone for helping out with this. This board is great and I can usually find the answers on other threads. You all do great work!
RE: Attachmate -> IE -> Attachmate
CODE
Sub Main()
<attachmate commands...>
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Visible = True
.Navigate "internal site"
Call Wait(objIE)
.Document.All("txtcovcode").Value = covcod
.Document.All("txtgroupnum").Value = grpnum
.Document.All("txtgroupbu").Value = bu
.Document.All("btnsearchnow").Click
Call Wait(objIE)
End With
Sess.Activate
<remaing attachmate commands...>
End Sub
Private Sub Wait(objIE As Object)
While objIE.Busy
DoEvents
Wend
While objIE.Document.ReadyState <> "complete"
DoEvents
Wend
End Sub
RE: Attachmate -> IE -> Attachmate
This is my first request, is there something I need to do to follow up on this?
Thanks again!
RE: Attachmate -> IE -> Attachmate
I'm assuming it's possible to check and see if a particular window is already open no?
Meaning, if the page is already open I would like it to just activate that page, but if not then I would like it to open one.
Is this possible?
RE: Attachmate -> IE -> Attachmate
CODE
Dim oWin As Object
Set oApp = CreateObject("Shell.Application")
For Each oWin In oApp.Windows
If InStr(oWin.Name, "Microsoft Internet Explorer") Then
sURL = oWin.LocationURL
On Error Resume Next
Set oTitle = oWin.Document.GetElementsByTagName("title")
On Error Goto 0
If oTitle Is Nothing Then
MsgBox oWin.Name & Chr(10) & sUrl
Else
MsgBox oTitle(0).innerHTML & " - " & oWin.Name & _
Chr(10) & sURL
End If
Set oTitle = Nothing
End If
Next
If it has a title it's an internet explorer window. If it doesn't, it's an explorer window. If you find the window you want based on URL or name, you just AppActivate it.
RE: Attachmate -> IE -> Attachmate
So how would this work for IE 7.0 and searching through Tabbed pages...if at all? Let's say I have an IE window open with 4 different tabs...is it possible for it to search through those as well?
Thanks again for not only helping but doing so kindly.
RE: Attachmate -> IE -> Attachmate
I just wish I had known about Sess.Activate a while back. When I tried to view the EXTRA library in the macro editor it would always crash on my old PC. It's (inconveniently) not listed in the help topics. I've hunted around in the object library in VBA but never saw this until now. You learn something new everyday.
RE: Attachmate -> IE -> Attachmate
For i = 1 to oWin.Documents.Count
Set oTab = oWin.Documents(i)
Next
You might want to try posting in an IE forum or either vbscript or javascript forums.
RE: Attachmate -> IE -> Attachmate
The window I am looking for is an IE window that will always have the same Title on the display bar but will not always have the same address. So I would only want to search for the page display Title. If the page is open then I want to activate it, if it is not then I would like to open a page to it.
So let's say that the display title for my page is "Display Title".
Where does that info go in the code?
What does the Chr(10) & sURL command refer to?
What does this command mean, 'MsgBox oTitle(0).innerHTML & " - " & oWin.Name & _'?
Where do I put the AppActivate command?
Sorry, I am used to working within Attachmate and this is the first I've moved to other applications. Any more help is greatly appreciated.
RE: Attachmate -> IE -> Attachmate
MsgBox oTitle.innerHTML & " - " & oWin.Name & Chr(10) & sURL
With this:
If oTitle(0).innerHTML = sTitle Then
oWin.Focus
End If
You can use the oWin.Focus (it may need to be oWin.Document.Focus), since it'll be more reliable than AppActivate.
RE: Attachmate -> IE -> Attachmate
Set oApp = CreateObject("Shell.Application")
For Each oWin In oApp.Windows
If InStr(oWin.Name, "Microsoft Internet Explorer") Then
sURL = oWin.LocationURL
On Error Resume Next
Set oTitle = oWin.Document.GetElementsByTagName("OBS - Online Benefits Search")
On Error Goto 0
If oTitle Is Nothing Then
MsgBox oWin.Name & Chr(10) & sUrl
Else
If oTitle(0).innerHTML = sTitle Then
oWin.Focus
End If
End If
Else
Set oTitle = Nothing
End If
Next
The first error is on the 'For Each' command, I am getting 'FOR syntax error'.
Then I am getting 'Unknown array or function: oTitle' on the If oTitle(0) line.
Then there are several 'FOR and NEXT statements must be in same block'.
RE: Attachmate -> IE -> Attachmate
CODE
Dim oWin As Object
Dim oTitle As Object
Dim iApp As Integer
Dim sURL As String
Set oApp = CreateObject("Shell.Application")
For iApp = 1 To oApp.Windows.Count
Set oWin = oApp.Windows(iApp)
If InStr(oWin.Name, "Microsoft Internet Explorer") Then
sURL = oWin.LocationURL
Set oTitle = Nothing
On Error Resume Next
Set oTitle = oWin.Document.GetElementsByTagName("title">
On Error Goto 0
If Not oTitle Is Nothing Then
If oTitle(0).innerHTML = "OBS - Online Benefits Search" Then
oWin.Focus
End If
End If
End If
Next
RE: Attachmate -> IE -> Attachmate
Set oWin = oApp.Windows(iApp)
Here is what I have...
Set oApp = CreateObject("Shell.Application")
For iApp = 1 To oApp.Windows.Count
Set oWin = oApp.Windows(iApp) ***This is line 86
If InStr(oWin.Name, "Microsoft Internet Explorer") Then
sURL = oWin.LocationURL
Set oTitle = Nothing
On Error Resume Next
Set oTitle = oWin.Document.GetElementsByTagName("title")
On Error Goto 0
If Not oTitle Is Nothing Then
If oTitle(0).innerHTML = "OBS - Benefit Summary Search" Then
oWin.Focus
End If
End If
End If
Next
RE: Attachmate -> IE -> Attachmate
Set oWin = oApp.Windows("iApp")
Sometimes you gotta leave your zone of safety. You have to manufacture Inspirado. You gotta get out of the apartment. You've got to run with the wolves. You've got to dive into the ocean and fight with the sharks. Or just treat yourself to a delicious hot fudge sundae........ with nuts. - Jack Black
RE: Attachmate -> IE -> Attachmate
RE: Attachmate -> IE -> Attachmate
I wasn't sure if it needed the -1 when I originally posted. I tend to use For Each loops with that object and haven't had to deal with it in EB.
RE: Attachmate -> IE -> Attachmate
IF the window is already open, perform
Call Wait(objIE)
objIE.Document.All("txtcovcode").Value = covcod
objIE.Document.All("txtgroupnum").Value = grpnum
objIE.Document.All("txtgroupbu").Value = bu
objIE.Document.All("btnsearchnow").Click
Call Wait(objIE)
If it is not open, perform
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Visible = True
.Navigate "http:/
End With
Call Wait(objIE)
objIE.Document.All("txtcovcode").Value = covcod
objIE.Document.All("txtgroupnum").Value = grpnum
objIE.Document.All("txtgroupbu").Value = bu
objIE.Document.All("btnsearchnow").Click
Call Wait(objIE)
I've tried several different variations but am not having any luck.
You've been a great help so far though. Thanks for any additional assistance.
RE: Attachmate -> IE -> Attachmate
I really need to avoid hit and runs when I don't have the time to read the whole post.
Sometimes you gotta leave your zone of safety. You have to manufacture Inspirado. You gotta get out of the apartment. You've got to run with the wolves. You've got to dive into the ocean and fight with the sharks. Or just treat yourself to a delicious hot fudge sundae........ with nuts. - Jack Black
RE: Attachmate -> IE -> Attachmate
CODE
Dim oApp As Object
Dim oWin As Object
Dim oTitle As Object
Dim iApp As Integer
Dim sURL As String
Set oIE = Nothing
Set oApp = CreateObject("Shell.Application")
For iApp = 1 To oApp.Windows.Count
Set oWin = oApp.Windows(iApp - 1)
If InStr(oWin.Name, "Microsoft Internet Explorer") Then
sURL = oWin.LocationURL
Set oTitle = Nothing
On Error Resume Next
Set oTitle = oWin.Document.GetElementsByTagName("title">
On Error Goto 0
If Not oTitle Is Nothing Then
If oTitle(0).innerHTML = "OBS - Online Benefits Search" Then
Set oIE = oWin
End If
End If
End If
Next
If oIE Is Nothing Then
Set oIE = CreateObject("InternetExplorer.Application")
With oIE
.Visible = True
.Navigate "http://wellnetapp.int.wellmark.com/secure/obs/search.asp"
Call Wait(objIE)
End With
End If
With oIE
.Document.All("txtcovcode").Value = covcod
.Document.All("txtgroupnum").Value = grpnum
.Document.All("txtgroupbu").Value = bu
.Document.All("btnsearchnow").Click
Call Wait(objIE)
End With
[/code]
RE: Attachmate -> IE -> Attachmate
"Object value is set to Nothing"
If InStr(oWin.Name, "Microsoft Internet Explorer") Then
CODE
Set oApp = CreateObject("Shell.Application")
For iApp = 1 To oApp.Windows.Count
Set oWin = oApp.Windows(iApp - 1)
If InStr(oWin.Name, "Microsoft Internet Explorer") Then
sURL = oWin.LocationURL
Set oTitle = Nothing
On Error Resume Next
Set oTitle = oWin.Document.GetElementsByTagName("title")
On Error Goto 0
If Not oTitle Is Nothing Then
If oTitle(0).innerHTML = "OBS - Benefit Summary Search" Then
Set oIE = oWin
End If
End If
End If
Next
If oIE Is Nothing Then
Set oIE = CreateObject("InternetExplorer.Application")
With oIE
.Visible = True
.Navigate "http://wellnetapp.int.wellmark.com/secure/obs/search.asp"
Call Wait(objIE)
End With
End If
With oIE
.Document.All("txtcovcode").Value = covcod
.Document.All("txtgroupnum").Value = grpnum
.Document.All("txtgroupbu").Value = bu
.Document.All("btnsearchnow").Click
Call Wait(objIE)
End With
RE: Attachmate -> IE -> Attachmate
CODE
Set oApp = CreateObject("Shell.Application")
For iApp = 1 To oApp.Windows.Count
Set oWin = oApp.Windows(iApp - 1)
If InStr(oWin.Name, "Microsoft Internet Explorer") Then
sURL = oWin.LocationURL
Set oTitle = Nothing
On Error Resume Next
Set oTitle = oWin.Document.GetElementsByTagName("title")
On Error Goto 0
If Not oTitle Is Nothing Then
If oTitle(0).innerHTML = "OBS - Benefit Summary Search" Then
Set oIE = oWin
End If
End If
End If
Next
If oIE Is Nothing Then
Set oIE = CreateObject("InternetExplorer.Application")
With oIE
.Visible = True
.Navigate "**internalsite url**"
Call Wait(oIE)
End With
End If
With oIE
.Visible = True
.Document.All("txtcovcode").Value = covcod
.Document.All("txtgroupnum").Value = grpnum
.Document.All("txtgroupbu").Value = bu
.Document.All("btnsearchnow").Click
Call Wait(oIE)
End With
End Sub
Private Sub Wait(oIE As Object)
While oIE.Busy
DoEvents
Wend
While oIE.Document.ReadyState <> "complete"
DoEvents
Wend
End Sub
The display title for the window I want to look for is exactly "OBS - Benefit Summary Search - Windows Internet Explorer". I have tried using that and w/o the Windows Internet Explorer portion but it just keeps opening a new window. Any thoughts?
RE: Attachmate -> IE -> Attachmate
The problem was this line
If InStr(oWin.Name, "Microsoft Internet Explorer") Then
The "suffix" for IE is 'Windows Internet Explorer' instead of 'Microsoft Internet Explorer'. I changed that and voila!
Thank you so much again for everything! I am sure I will have some other questions but I'm off for the weekend so take it easy! Enjoy!
RE: Attachmate -> IE -> Attachmate
CODE
If oTitle(0).innerHTML = "OBS - Benefit Summary Search" Then
Set oIE = oWin
End If
End If
CODE
If InStr(oTitle(0).innerHTML, "OBS - Benefit Summary Search") Then
Set oIE = oWin
End If
End If
If that doesn't work, you might want to MsgBox back the oTitle(0).innerHTML to see what it says the title is.
RE: Attachmate -> IE -> Attachmate
RE: Attachmate -> IE -> Attachmate
RE: Attachmate -> IE -> Attachmate
CODE
If oWin.LocationURL(0).innerHTML = "http://www.google.com" Then
Set oIE = oWin
oWin.Focus
With oIE
.Visible = True
.Navigate "http://www.tek-tips.com"
Call Wait(oIE)
End With
This compiles fine but when I run it I get an error that says 'no such property or method' on the line 'If Not oWin.LocationURL is Nothing Then' line. Do you see anything wrong with this?
RE: Attachmate -> IE -> Attachmate