473,505 Members | 15,036 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use VBA to activate JavaScript checkbox function in IE6?

Ed
I'm writing a VBA macro in Word 2003 that finds and manipulates a web
page (Win XP, IE6 sp2). I am having trouble with a checkbox. I can
find the checkbox and make it checked, but I can't figure out how to
activate the function connected to the OnClick event. Would anyone be
able to help me out here, please?

Thanks.
Ed

Jun 19 '07 #1
4 5864

Ed wrote:
I'm writing a VBA macro in Word 2003 that finds and manipulates a web
page (Win XP, IE6 sp2). I am having trouble with a checkbox. I can
find the checkbox and make it checked, but I can't figure out how to
activate the function connected to the OnClick event. Would anyone be
able to help me out here, please?

checkboxElement.onclick()

Jun 20 '07 #2
Ed
On Jun 19, 4:55 pm, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
Ed wrote:
I'm writing a VBA macro in Word 2003 that finds and manipulates a web
page (Win XP, IE6 sp2). I am having trouble with a checkbox. I can
find the checkbox and make it checked, but I can't figure out how to
activate the function connected to the OnClick event. Would anyone be
able to help me out here, please?

checkboxElement.onclick()
I tried
objCB.checkboxElement.onclick()
and
objCB.onclick()
and VBA kept giving me an error message that it expects an = after the
expression.
So I tried
objCB.onclick() = "selectAllCheckboxes"
which is the name of the function called by the onClick event, and
still nothing happened. (Checking this one box activates a function
which checks all boxes on the page.)

Here's what I've got so far:
Dim objCB
Set objCB = docIE.getElementById("selectAllCB")
objCB.Checked = True ' This does check the box, but only this box.
' None of these activate the function to select all the boxes.
objCB.onclick = "selectAllCheckboxes"
Call
docIE.parentWindow.execScript("javascript:selectAl lCheckboxes",
"JavaScript")
objCB.onclick() = "selectAllCheckboxes"

If you could drop-kick me a bit further down the road on this, I would
be very grateful.

Ed

Jun 20 '07 #3
On Jun 20, 7:43 am, Ed <prof_ofw...@yahoo.comwrote:
On Jun 19, 4:55 pm, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
Ed wrote:
I'm writing a VBA macro in Word 2003 that finds and manipulates a web
page (Win XP, IE6 sp2). I am having trouble with a checkbox. I can
find the checkbox and make it checked, but I can't figure out how to
activate the function connected to the OnClick event. Would anyone be
able to help me out here, please?
checkboxElement.onclick()

I tried
objCB.checkboxElement.onclick()
and
objCB.onclick()
and VBA kept giving me an error message that it expects an = after the
expression.
So I tried
objCB.onclick() = "selectAllCheckboxes"
which is the name of the function called by the onClick event, and
still nothing happened. (Checking this one box activates a function
which checks all boxes on the page.)

Here's what I've got so far:
Dim objCB
Set objCB = docIE.getElementById("selectAllCB")
objCB.Checked = True ' This does check the box, but only this box.
' None of these activate the function to select all the boxes.
objCB.onclick = "selectAllCheckboxes"
Call
docIE.parentWindow.execScript("javascript:selectAl lCheckboxes",
"JavaScript")
objCB.onclick() = "selectAllCheckboxes"

If you could drop-kick me a bit further down the road on this, I would
be very grateful.
Why dont you write your own VB function to check all checkboxes. try
this:
Set checks=document.getelementsbytagname("input")
for each check in checks
if check.type="checkbox" then check.checked=true
next
OR try this if you have to use the selectAllCheckboxes function:
docIE.parentWindow.location.href="javascript:selec tAllCheckboxes()"

OR
docIE.parentWindow.execScript("javascript:selectAl lCheckboxes()","JavaScript")

OR
Dim objCB
Set objCB = docIE.getElementById("selectAllCB")
objCB.Checked = True
objCB.onclick

Jun 20 '07 #4
Ed
On Jun 20, 7:02 am, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
On Jun 20, 7:43 am, Ed <prof_ofw...@yahoo.comwrote:
>>snip<<
OR
Dim objCB
Set objCB = docIE.getElementById("selectAllCB")
objCB.Checked = True
objCB.onclick
That was it! So simple that I couldn't see it. Thank you very much!

Ed

Jun 20 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1328
by: dougloj | last post by:
I'm developing an ASP.Net application that uses checkboxes. I am trying to use client-side Javascript to capture the clicking of a checkbox when it happens via the OnClick event. In my .aspx...
2
2874
by: Kenneth | last post by:
Hi, In a document I have three lines that detects and redirects to another page is a session variable is 0 If Session("Customer_ID")=0 Then Response.Redirect("myPage.aspx") End If What I...
2
2219
by: ljlolel | last post by:
I'm posting this again because I did not explain myself well the first time, so the problem was not being addressed. I made the following page (...
0
2666
by: Boricua | last post by:
I'm using ASP.NET 2.0 I got an imagebutton at the end of my form as a submit button. When the user clicks it the button becomes disabled and continues with the postback. This is what I got, ib...
4
2818
by: narsibvl | last post by:
Here is a piece of html code <form name="package_information" id="package_information" method="post" enctype="multipart/form-data""& lt;" <tr> <td><input type="checkbox"...
4
5655
by: Waldy | last post by:
Hi there, I have a customer requirement to provide a web application without JavaScript. A function is being written to the HTML output on some pages. The function is called __doPostBack. How...
4
6132
by: ameshkin | last post by:
I have a checkbox with an ID of svc_tp_1, and an image that corresponds with this checkbox below it. <input type="checkbox" name="checkbox" id="svc_tp_1" value="svc_tp_1" / <img...
22
2708
by: Mike1961 | last post by:
Checkbox values Hello. I have a problem with this code ASP / Javascript. The problem is JavaScript; try this LINK and select value cespiti 1) With ASP language is populated a secondary...
17
2937
by: happyse27 | last post by:
Hi All, The html page(see item a below) is calling javascript(item b below), but cant work as the page show blank. Not sure if the method of calling is wrong(in terms of default directory) or...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7018
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.