×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Attachmate -> IE -> Attachmate
2

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!

RE: Attachmate -> IE -> Attachmate

2
Basically, this is all you should need to do.

'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

(OP)
Currently this is the code I have for opening IE and performing the search.

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

For some reason I was thinking you wanted this looped.  But, it looks like you just want to do stuff in Attachmate after the search?

CODE

<Attachmate Commands...>
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

(OP)
Thanks.  I am pretty comfortable with dialog boxes and the editor.  I know the code I need once I get back into the session, I am just having troubles getting back to the session from IE.

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

Try the AppActivate function instead of Sess1.Activate.  Whatever your session displays in the Title Bar is what you put in quotes.  Mine works like this:

CODE

AppActivate "SESSION1 - EXTRA! for NetWare"

RE: Attachmate -> IE -> Attachmate

Yeah, you still need your Sub Wait for IE.  What I provided should only replace the following from the Main Sub:

CODE

<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)

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.

Quote:

Applies To Objects
Session

Description
Makes the specified session the active window.

Syntax
object.Activate

Element    Application
object    The Session object.

Quote:

AppActivate string-expression

Activates an application window.

Parameter    Description
string-expression    The name (from the title bar) of the application you want to activate. Both the title bar and string-expression must be spelled identically. However, the comparison is not case sensitive.

RE: Attachmate -> IE -> Attachmate

(OP)
Thanks Skie.  I tried the appactivate but the only concern I have with that is that I need this to work for many people and some people have decided to rename their sessions.

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

You need to End Sub for the Sub Main before you have Sub Wait.

CODE

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)
  
  .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

(OP)
FINALLY!  Thank you so much!  I was about ripping my hair out trying to figure this out.  I really appreciate your help on this!

This is my first request, is there something I need to do to follow up on this?

Thanks again!

RE: Attachmate -> IE -> Attachmate

(OP)
Okay, so further question.

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 oApp As Object
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

(OP)
How do you stay so patient helping those of us who are way out of our league when it comes to this stuff?

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

Quote (Skie):

You can use AppActivate, but Sess.Activate is going to be more accurate.

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

I haven't done much with IE7.0.  I did a quick search on how you'd find out what was in each tab, but couldn't find any code for it.  I don't know if it's a simple as something like:

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

(OP)
Okay, I'm having trouble understanding what information needs plugged in where...or what exactly the code is doing/looking for etc...

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

Replace this:
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

(OP)
I'm getting a ton of errors trying to use this.

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

Sorry, I forgot EB doesn't have For Each

CODE

Dim oApp As Object
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

(OP)
Awesome, thanks!  It compiles successfully but when I run it I am getting an 'object error, Line Number: 86'.  Line 86 is...

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

try with quotes

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

(OP)
Same situation.  Compiles but hits an error at that line.

RE: Attachmate -> IE -> Attachmate

Set oWin = oApp.Windows(iApp - 1)

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

(OP)
Fantastic.  Okay, it compiles and it runs, now I need to figure out how to arrange the logic.

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://wellnetapp.int.wellmark.com/secure/obs/search.asp"
     
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

Horrible advice sory,  I didn't look far enough to see that iApp was an integer and you were looking by index rahter than title.  

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

Something like this...

CODE

Dim oIE As Object
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

(OP)
Compiles successfully, now getting an error while running for the following line...

"Object value is set to Nothing"
If InStr(oWin.Name, "Microsoft Internet Explorer") Then

CODE

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 - 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

(OP)
Okay, I got the macro to compile and to run without error but it is not doing what I had wanted it to do.  It is still opening a new window each time, despite there already being a window open...  Here is the code that I have...

CODE

        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 - 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

(OP)
Okay, finally figured it out!

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

Modify this section:

CODE

If Not oTitle Is Nothing Then
  If oTitle(0).innerHTML = "OBS - Benefit Summary Search" Then
    Set oIE = oWin
  End If
End If
to:

CODE

If Not oTitle Is Nothing Then
  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

(OP)
Thanks again for everything.  The original macro I needed help with has been completed and working great.  I have another question regarding another macro.  Instead of searching by the Display Name, I would like to now search by the URL of the open internet windows.  Is it fairly similar to searching by title?  Thanks again for all your help!

RE: Attachmate -> IE -> Attachmate

Yep, just use oWin.LocationURL instead of the oTitle.

RE: Attachmate -> IE -> Attachmate

(OP)

CODE

If Not oWin.LocationURL Is Nothing Then
       
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?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close