2

Don't know how to do this at all, but if the onclick of a button is similar to below:

onclick="ConfirmAvailable();"
function ConfirmAvailable()
{
    if (document.getElementById("AvailableCB").checked)
    {
        return YesNoDialog("'Are you sure?'");
    }
    else
    {
        return true;
    }
}

Is it possible, if I set ConfirmAvailable()="" using Excel VBA, to reset it to what is above, or even to set the output to =true all the time? The results are passed to another function, so I need it to return true, but ideally, I'd like to change it to nothing, then return it to its original state, if possible. Any help would be appreciated, as I'm not good with this stuff.

4
  • Are you sure you don't mean JavaScript? Also, "Confrim"? Commented Jun 30, 2009 at 13:32
  • Assuming he meant Javascript... edited Commented Jun 30, 2009 at 13:35
  • you will be damned doing so :-) Commented Jun 30, 2009 at 13:41
  • Hi, This is the script from the webpage. I can change the script using excel vba to make the function ="", but I can't change it back to = the correct function as above. (Also fixing the ConfrimAvailable() to ConfirmAvailable()) Commented Jun 30, 2009 at 13:48

3 Answers 3

1

Assuming the Checkbox's name is AvailableCB, and the name of the button is ConfirmAvailable, the VBA version of what you're looking to do should look something like this.

   Public Function ConfirmAvailable_Click()
       ConfirmAvailable_Click = False ' default value = false '
       If AvailableCB.Value = True Then ConfirmAvailable_Click = True ' if checked, true '
   End Function

If the button name is something else, just call this function from its _Click() method.

Sign up to request clarification or add additional context in comments.

11 Comments

Thanks A. Scagnelli. I'll give it a go. Is it possible to get VBA to rewrite the function to be the same as above?
Doesn't really work, as its writing an Excel VBA function, but won't replace the existing function. Is it possible to do this, or to get the onclick to call a different function? The function would have to be loaded somewhere that the page can take it from.
The above is a VBA function. What are you asking for when you say "Is it possible to get VBA to rewrite the function to be the same as above"?
Hi. Sorry if I'm not being clear. Basically, I'm trying to turn off the function above in a VBA macro, and pass the result of true to the next java function, then replace the function as it was, so that I leave the page as I originally found it.
Ah. You might want to try setting the function to NULL inside the JavaScript, then.
|
1

Simple answer: try turning off JavaScript in the browser. An onclick macro that returns true or false often controls whether a link should be followed or not. If JavaScript is off then the link should be followed regardless. Whether this works will depend on how much of the rest of the site requires JavaScript to be enabled

1 Comment

Hi barrowc, unfortunately JavaScript is required for many other items in the page. does anyone know if its possible to inject code into the page?
1

I've found this seems to work if I save the page to my C drive, but this does not accept the changes on the "live" page, and I don't have permission to make the change on the "live" page.

WebBrowser1.document.btnwhatever.attachEvent "onclick", WebBrowser1.document.parentWindow.next_clicked()

I still don't know how to change the function next_clicked(), or the format to pass it back to the page, but as I don't have access on the "live" page I can't do it anyway.

Thanks all for the help and for looking into this for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.