I am trying to automatically delete items from an in house intranet
website.
I have the code that works upto the point of "delete" button pressing,
and I have the code that works to press the next confirmation button.
Each portion has been tested and works fine.

The problem is that the code STOPS, as soon as the code presses the
"DELETE" button, until the CONFIRM button is MANUALLY pressed, then
the code codes about it's merry way.
the call is
BACCDeleteSN(o_BACCDeleteSN,BACCDeleteSN_SN ) whereas o_BACCDeleteSN
is the handle for the web page and then the BACCDeleteSN_SN is the
specific serial number I am wanting to delete.

[code]
Sub BACCDeleteSN(o_BACCDeleteSN As Object, BACCDeleteSN_SN As String)
' Open 1 instance of BTS

'Verify we are deleting the right BACC
'With o_BACCDeleteSN.document.BACCMtaSearchBean
    o_BACCDeleteSNPage = LCase
(o_BACCDeleteSN.document.DocumentElement.outerHTML)
    BACCDeleteSN_SNTest = LCase(SNExpanded(BACCDeleteSN_SN))
    If InStr(1, o_BACCDeleteSNPage, BACCDeleteSN_SNTest,
vbTextCompare) > 0 Then
        Set o_BACCDeleteSNInputs =
o_BACCDeleteSN.document.getElementsByTagName("input")
        o_BACCDeleteSN.document.BACCMtaSearchBean.SelectAll.Click
        'Set o_BACCDeleteSNBTNELEMENTCOL =
o_BACCDeleteSN.document.getElementsByTagName("INPUT")

        For Each btnInput In o_BACCDeleteSNInputs
            If btnInput.Value = " DELETE " Then
                btnInput.Click         ' <- Everything works fine, to
this point
               'SendMessage Hndb, BM_CLICK, 0, 0
             MsgBox "Here 1"  '<- It never makes it here unless I
MANUALLY press the confirmation button.
                Exit For
            End If
        Next btnInput
         ' MsgBox "Here"
 Call DeleteBacc  '<-This is the call for where the code SHOULD press
the button, but it never gets here...

    End If


End Sub
[/code]

Here is the DELETEBACC, but it never gets here
[code]
Sub DeleteBacc()

    Dim hwnd As Long, hWnd1 As Long, hWnd2 As Long, HWND3 As Long,
HWND4 As Long, HWND5 As Long, HWNDCont As Long, HWNDCont1 As Long
    Dim Textlen As Long, FSO As Object, Carpeta As Object
    Dim Texte As String, Txt As String, I As Integer, j As Integer, K
As Integer
    Dim tRECT As RECT
    HWNDCont = 9999
    While HWNDCont <> 0
        Set WshShell = CreateObject("WScript.Shell")
        'Iterate in order to minimize waiting for the window. When you
get the handle: exit the bucle
        For I = 1 To 12
            hwnd = FindWindow("#32770", "Microsoft Internet Explorer")
            If hwnd > 0 Then
                z2 = EnumChildWindow(hwnd, 0)
                Debug.Print z2
                test1 = False
                EnumChildWindow hwnd, 0   ' one call directly to list
parent
                EnumChildWindows hwnd, AddressOf EnumChildWindow, 0

                'FindBACCDelete hwnd, AddressOf EnumChildWindow, 0
                If test1 Then
                    MsgBox "Gotit!"
                    For j = 1 To 30
                        Hndb = FindWindowEx(hwnd, 0, "Button", "OK")
                        If Hndb > 0 Then

                            GetWindowRect Hndb, tRECT
                            'Get the regtancle of the botton and
compute the middle point
                            With tRECT
                                x = .Left + (.Right - .Left) / 2
                                Y = .Top + (.Bottom - .Top) / 2
                            End With
                            'select the window
                            SetForegroundWindow hwnd
                            'place the pointer on the middle point
                            SetCursorPos x, Y
                            Delay 0.3
                            DoEvents
                            'click the button
                            SetActiveWindow Hndb

                            SendMessage Hndb, BM_CLICK, 0, 0
                            Delay 0.3
                            '  SendMessage hndb, BM_CLICK, 0, 0
                            Exit For
                        Else
                            Delay 0.2
                        End If
                        Debug.Print "J", j
                    Next j
                    Exit For
                End If    'test1

            Else
                Delay 0.5
            End If
            Debug.Print "I", I


        Next I



    Wend

End Sub
[/code]


Here is the code from the WEBSITE (I am not good at HTML.....) I do
NOT have any CONTROL ON THE WEBSITE! I have to live with what is
there...

Here is the button calling code
[code]
<input type="button" onClick="return clickDelete();" value=" DELETE "
name="deletebutton"
[/code]

And here is the processing code for the button

[code]
function clickDelete()
{
  var x, y;
  if (document.BACCMtaSearchBean.delmacaddr)
  {
    x = document.BACCMtaSearchBean.delmacaddr;
    y = false;
    if (x.checked == true)
      y = true;
    for (i = 0; i < x.length; i++)
    {
      if (x[i].checked == true)
      {
        y = true; break;
      }
    }
    if (y == false)
    {
      alert('No device(s) selected to delete. Please select device
(s).');
      return false;
    }

    var input_box=confirm("Are you sure you want to Delete the device
(s)?");
    if (input_box== false)
    {
      return false;
    }

    document.BACCMtaSearchBean.action.value="DELETE_DEVICES";
    document.body.style.cursor = "wait";
    document.BACCMtaSearchBean.searchbutton.disabled=true;
    document.BACCMtaSearchBean.submit();
  }
}
[/code]




Is it the way I am opening the web page? Is there a way to have the
page release until I can press the button?
Would putting my confirmation button press code in a CLASS help? I am
very new to using classes!!!! I don't fully understand them.

Help!

Thanks!
Mc

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to [email protected]
If you find any spam message in the group, please send an email to:
Ayush Jain  @ [email protected] or
Ashish Jain @ [email protected]
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,500 subscribers worldwide and receive many nice notes about the 
learning and support from the group. Our goal is to have 10,000 subscribers by 
the end of 2009. Let friends and co-workers know they can subscribe to group at 
http://groups.google.com/group/excel-macros/subscribe

Reply via email to