Results 1 to 14 of 14

Thread: [RESOLVED] Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Posts
    340

    Resolved [RESOLVED] Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    please some one help me out. i got stuck on my project what deadline is already passed

    i can't figure out how to .. set/get value objects under web browser controls forms.

    please see the attached file for source code of the page

    i use HTML Object library.. but no way.from my end

    so, i request from some help..

    this is the part of source code i am using:
    Code:
        Dim objHTMLdoc As HTMLDocument
        Dim objHTMLinp As HTMLInputElement
        Dim objHTMLbut As HTMLButtonElement
        Dim objHTMLSelect As HTMLSelectElement
        Dim objHTMLLink As HTMLAnchorElement
        Dim objHTMLForm As HTMLFormElement
    
        Set objHTMLdoc = webMain.Document
        Set objHTMLForm = objHTMLdoc.getElementById("Form1")
        MsgBox objHTMLForm.Name (give error "object varaible not set" error num-91)
        Set objHTMLinp = objHTMLdoc.getElementById("ctl06_KeepCopyCheckBox")
        objHTMLinp.Checked = True (same error here)
    please check the source code (attached) for the placement of the id/object "ctl06_KeepCopyCheckBox"

    please any one hlep me out asap.. as i am in grave danger

    best regards
    kamrul hassan
    Attached Files Attached Files

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Posts
    340

    Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    here is the iMacros code what works perfectly. but no on vb (html object libray)

    Code:
    FRAME F=1
    TAG POS=1 TYPE=INPUT:RADIO FORM=ID:Form1 ATTR=ID:ctl06_RadioOff
    TAG POS=1 TYPE=INPUT:RADIO FORM=ID:Form1 ATTR=ID:ctl06_RadioOn
    TAG POS=1 TYPE=INPUT:RADIO FORM=ID:Form1 ATTR=ID:ctl06_RadioOff
    TAG POS=1 TYPE=TEXTAREA FORM=ACTION:options.aspx?subsection=32&n=1508461237 ATTR=ID:ctl06_AddressTextBox CONTENT=iloveyou
    TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:options.aspx?subsection=32&n=1508461237 ATTR=ID:ctl06_KeepCopyCheckBox CONTENT=YES
    TAG POS=1 TYPE=INPUT:RADIO FORM=ID:Form1 ATTR=ID:ctl06_RadioOff
    i am waiting for any kind solution ...

    best regards
    kamrul hassan

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    using your attached file, i tried like
    vb Code:
    1. Set wb = CreateObject("internetexplorer.application")
    2. wb.navigate2 "c:\temp\sample source.html"
    3. Do Until wb.readystate = 4
    4.     DoEvents
    5. Loop
    6. Debug.Print wb.document.getelementbyid("ctl06_KeepCopyCheckBox").Value  ' on
    7. wb.Quit
    8. Set wb = Nothing
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Posts
    340

    Unhappy Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    Quote Originally Posted by westconn1 View Post
    using your attached file, i tried like
    vb Code:
    1. Set wb = CreateObject("internetexplorer.application")
    2. wb.navigate2 "c:\temp\sample source.html"
    3. Do Until wb.readystate = 4
    4.     DoEvents
    5. Loop
    6. Debug.Print wb.document.getelementbyid("ctl06_KeepCopyCheckBox").Value  ' on
    7. wb.Quit
    8. Set wb = Nothing
    thanks for your replied but as i told it is a part of a ongoing project.. so i have to use HTML object library not Web Browser Application..

    please any one help me out..

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    Set objHTMLdoc = webMain.Document
    i assumed that you were already using some form of web browser (webmain)

    i went to test this again on a different machine and it crashed internet explorer everytime i tired to open the page (whether by code or manually), although it opened correctly in firefox

    i tested your code again, using a htmldocument object with a different webpage and do not see any reason why it should not work, considering a webbrowser document is an htmldocument, of course if the page fails to load correctly, as it does on this machine, then you would get those type of errors i will try again tonight on the other machine, where the document will load for whatever reason that it works on one version of IE (or OS), but not another
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Posts
    340

    Unhappy Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    Quote Originally Posted by westconn1 View Post
    i assumed that you were already using some form of web browser (webmain)

    i went to test this again on a different machine and it crashed internet explorer everytime i tired to open the page (whether by code or manually), although it opened correctly in firefox

    i tested your code again, using a htmldocument object with a different webpage and do not see any reason why it should not work, considering a webbrowser document is an htmldocument, of course if the page fails to load correctly, as it does on this machine, then you would get those type of errors i will try again tonight on the other machine, where the document will load for whatever reason that it works on one version of IE (or OS), but not another
    thanks a lot..as you tried.. ok.. i also tried to open the source same..

    so, i think if i gave you the proper link then you may help me out..

    1. first go to this link :
    Code:
    https://login.live.com
    2. now please log in with any of your hot-mail id, if you don't have i request you to create on.

    3. after log in proceed finished.. go/navigate this page:
    Code:
    http://by145w.bay145.mail.live.com/mail/options.aspx?subsection=32&n=1508461237
    4. and now please try my code.. and you will find out the problem.For your kind information here webmain is the web browser control name.
    Code:
        Dim objHTMLdoc As HTMLDocument
        Dim objHTMLinp As HTMLInputElement
        Dim objHTMLForm As HTMLFormElement
        Set objHTMLdoc = webMain.Document
        Set objHTMLForm = objHTMLdoc.getElementById("Form1")
        MsgBox objHTMLForm.Name
        Set objHTMLinp = objHTMLdoc.getElementById("ctl06_KeepCopyCheckBox")
        objHTMLinp.Checked = True
    i hope, now you , or any one have better scope to help me out...

    please some one.. do it fast, as i am almost losing this project just for this problem

    best regards
    kamrul hassan

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    i tested your code again, using your sample source from post #1, it worked on this machine without error

    i do not have a windows live id and see no reason to get one now

    the same code works on one machine, but fails on another, for this specific web page
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Posts
    340

    Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    Quote Originally Posted by westconn1 View Post
    i tested your code again, using your sample source from post #1, it worked on this machine without error

    i do not have a windows live id and see no reason to get one now

    the same code works on one machine, but fails on another, for this specific web page
    ok, then would you please check the attached file..

    i give a sample vb6 project with a working id..

    after checking please brother update me asap

    best regards
    kamrul hassan
    Attached Files Attached Files

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Posts
    340

    Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    no one here to help me out?

  10. #10
    Junior Member
    Join Date
    Jun 2011
    Location
    Iran [Islamic Republic]
    Posts
    28

    Resolved Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    Thanks, comments was useful
    Last edited by msnv; Jul 18th, 2011 at 10:22 PM.

  11. #11
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    vb Code:
    1. mahabub_part:
    2.     Set objHTMLinp = objHTMLdoc.frames(2).document.getElementById("ctl06_KeepCopyCheckBox")
    3.     MsgBox objHTMLinp.Value
    for some reason you can not use for each with frames
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Posts
    340

    Cool Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    Quote Originally Posted by westconn1 View Post
    vb Code:
    1. mahabub_part:
    2.     Set objHTMLinp = objHTMLdoc.frames(2).document.getElementById("ctl06_KeepCopyCheckBox")
    3.     MsgBox objHTMLinp.Value
    for some reason you can not use for each with frames
    thanks a lot it's hope working..

    but sometimes it gave same error (error no-91 "Object variable...."

    and also how should i know, in which frames object are exits?

    if you check the iMacros code in previous replies you will see it says F=1, but you use frame 2?

    am i clear sir? i hope so..

    please sir, leave a reply asap

    thanks again for your kind effort

    best regards
    kamrul hassan

  13. #13
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    and also how should i know, in which frames object are exits?
    i loop all the frames till i find the desired element

    vb Code:
    1. for i = 1 to objhtmldoc.frames.length
    2.   for each ele in objhtmldoc.frames(i).document.all
    3.        if ele.id = "ctl06_KeepCopyCheckBox" then msgbox "ele in frame " & i : exit for  ' or keep going if element could occur in more than one frame
    4.   next
    5. next

    working with html elements in frames can be difficult
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Posts
    340

    Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?

    Quote Originally Posted by westconn1 View Post
    i loop all the frames till i find the desired element

    vb Code:
    1. for i = 1 to objhtmldoc.frames.length
    2.   for each ele in objhtmldoc.frames(i).document.all
    3.        if ele.id = "ctl06_KeepCopyCheckBox" then msgbox "ele in frame " & i : exit for  ' or keep going if element could occur in more than one frame
    4.   next
    5. next

    working with html elements in frames can be difficult
    thanks a lot.. as it works..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width