[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
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
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
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
Re: Set/Get Value From Webborwser Forms Elemetns.. ? Nee help?
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:
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
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
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
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
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:
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
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