1 Attachment(s)
[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
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
Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?
using your attached file, i tried like
vb Code:
Set wb = CreateObject("internetexplorer.application")
wb.navigate2 "c:\temp\sample source.html"
Do Until wb.readystate = 4
DoEvents
Loop
Debug.Print wb.document.getelementbyid("ctl06_KeepCopyCheckBox").Value ' on
wb.Quit
Set wb = Nothing
Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?
Quote:
Originally Posted by
westconn1
using your attached file, i tried like
vb Code:
Set wb = CreateObject("internetexplorer.application")
wb.navigate2 "c:\temp\sample source.html"
Do Until wb.readystate = 4
DoEvents
Loop
Debug.Print wb.document.getelementbyid("ctl06_KeepCopyCheckBox").Value ' on
wb.Quit
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..
Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?
Quote:
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
Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?
Quote:
Originally Posted by
westconn1
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
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
1 Attachment(s)
Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?
Quote:
Originally Posted by
westconn1
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
Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?
no one here to help me out? :(
Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?
Thanks, comments was useful:check:
Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?
vb Code:
mahabub_part:
Set objHTMLinp = objHTMLdoc.frames(2).document.getElementById("ctl06_KeepCopyCheckBox")
MsgBox objHTMLinp.Value
for some reason you can not use for each with frames
Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?
Quote:
Originally Posted by
westconn1
vb Code:
mahabub_part:
Set objHTMLinp = objHTMLdoc.frames(2).document.getElementById("ctl06_KeepCopyCheckBox")
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
Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?
Quote:
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:
for i = 1 to objhtmldoc.frames.length
for each ele in objhtmldoc.frames(i).document.all
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
next
next
working with html elements in frames can be difficult
Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?
Quote:
Originally Posted by
westconn1
i loop all the frames till i find the desired element
vb Code:
for i = 1 to objhtmldoc.frames.length
for each ele in objhtmldoc.frames(i).document.all
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
next
next
working with html elements in frames can be difficult
thanks a lot.. as it works..