Results 1 to 6 of 6
  1. #1
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480

    What rule am I breaking? Integer or sub problem.

    So I am doing something wrong. But I have no idea what. When I try to run the code "MSecs" shows as the error and I receive the message...


    "Compile Error:
    ByRef argument type mismatch"

    What am I doing wrong here?




    Here is the call
    Code:
    Call ConfirmIE(oie, "Fail", 500, 5) ' In this case, I want to look at oie, for the word fail. Wait 1/2 a second and loop upto 5 times.....
    Here is the code
    Code:
    Sub ConfirmIE(oie As InternetExplorer, TextNeeded As String, MSecs, MaxLoop As Integer)
    LoopCt = 0
      Do Until InStr(oie.document.body.innerText, TextNeeded) > 0
        Call SleepIE(oie)
        PauseApp MSecs
          If LoopCt = MaxLoop Then GoTo ExitLoop
        LoopCt = LoopCt + 1
      Loop
    GoTo Exit_Sub:
      
    ExitLoop:
     MsgBox "whatever you want here. it'd be nice to have a stack of solutions coded. Or a msgbox giving the user the choice of the outcome..."
    Exit_Sub:
    End Sub

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    In you sub statement, you have not indicated correctly that MSecs is an integer - Access wil treat it as a Variant. You need to have

    Sub ConfirmIE(oie As InternetExplorer, TextNeeded As String, MSecs as integer, MaxLoop As Integer)

    See if making that change fixes the problem, otherwise:

    How are you declaring and/or defining (Dim..) oie in you main program, before the call?

    Do you have a reference that allows you to use oie As InternetExplorer, or did you define it as a user-defined type? It does not appear to be part of A2010.

  3. #3
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Well I made the change to

    Code:
    Sub ConfirmIE(oie As InternetExplorer, TextNeeded As String, MSecs As Integer, MaxLoop As Integer)
    But still get the same error.



    "How are you declaring and/or defining (Dim..) oie in you main program, before the call? "
    I'm using the Microsoft internet controls reference library. and oie is dimed as
    Code:
      Dim oie As InternetExplorer
      Set oie = FindIE("Companyintraneturlgoesinhere")
    And the FindIE function then loops IE windows to confirm an IE window with the URL is actually open. If it is, then oie comes back as oie= Internet Explorer and if its not open it comes back as oie is nothing.

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    When you do the compile, what line is causing the error, and what part of the line is highlighted?

  5. #5
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    When I try to compile, this is the line that is shown.

    PauseApp Msecs

    and Msecs is highlighted yellow.



    I tried doing the same thing with only oie and textneeded and it worked, so I know its something with the msecs.. oy.




    Okay, figured it out. The problem was with the pauseapp routine. I changed that to call Appsleep(Msecs) and it is working now. Wow...

  6. #6
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Take a look at it since its working now. Gar.


    Code:
    Call ConfirmIE(oie, "Fail", 500, 10)
    Code:
    Sub ConfirmIE(oie As InternetExplorer, TextNeeded As String, MSecs As Integer, MaxLoop As Integer)
    LoopCt = 0
      Do Until InStr(oie.document.body.innerText, TextNeeded) > 0
        Call SleepIE(oie)
        Call AppSleep(MSecs)
          If LoopCt = MaxLoop Then GoTo ExitLoop
        LoopCt = LoopCt + 1
      Loop
    GoTo Exit_Sub:
      
    ExitLoop:
    Call IEresp(oie, TextNeeded, MSecs, MaxLoop)
    Exit_Sub:
    End Sub
    Code:
    Sub IEresp(oie As InternetExplorer, TextNeeded As String, MSecs As Integer, MaxLoop As Integer)
    Restart:
        repl = InputBox("The webpage is not on the correct page, How would you like to proceed?" & vbCr & vbCr & "Please enter a number selection" & vbCr & _
        "1 = End the Macro" & vbCr & "2 = Continue to wait for the page" & vbCr & "3 = Play a guessing game")
                If repl = "1" Then
                MsgBox ("Ended")
                End
                End If
                If repl = "2" Then
                valid = "Yes"
                Call ConfirmIE(oie, TextNeeded, MSecs, MaxLoop)
                End If
                If repl = "3" Then
                valid = "Yes"
                MsgBox "ba da da daa da da da, yea I don't know"
                End If
                If valid <> "Yes" Then
                MsgBox "Please select a valid response" & vbCr & "Examples are 1, 2, 3, etc, etc", vbCritical
                  GoTo Restart:
                End If
    End Sub

    I plan on building out IEresp to be unique to each process, but it will be nice to have a standard format with everything moving forward.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Breaking down a table with too many fields
    By maultiper in forum Database Design
    Replies: 3
    Last Post: 01-07-2016, 01:41 PM
  2. Database breaking
    By jj1 in forum Access
    Replies: 5
    Last Post: 11-25-2014, 02:17 PM
  3. Breaking Up table in FK and PK
    By drunkenneo in forum Programming
    Replies: 6
    Last Post: 12-07-2013, 12:59 AM
  4. Replies: 2
    Last Post: 10-25-2012, 02:39 PM
  5. Adding column as INTEGER makes it a long integer?
    By luckycharms in forum Programming
    Replies: 2
    Last Post: 10-20-2010, 02:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums