+ Reply to Thread
Results 1 to 15 of 15

ppDisp to display popup into form2

  1. #1
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    ppDisp to display popup into form2

    I am using a web browser control inside userform1. The web page I am browsing with it generates popups, and I need to take control of the popup (it inserts values into specific fields related to the option that forces the onchange event). Either by using a userform or ppDisp. I cannot get ppDisp to work correctly to display on form2. The easiest way to solve this issue is to get ppDisp to work correctly)


    Please Login or Register  to view this content.
    This works only one time. Once the popup closes itself and inserts values into my web browser control, the web browser2 will not pop up again, so the web browser control needs to create itself on the fly or not let the popup close it out completely. I would also like to see if I can get this on its own form. I can use excel or access, but I believe there is little difference concerning vba/forms.

    So In short:

    On each new_window event that occurs in my web browser control on userform1, I need to send the popup to display in userform2''s web browser control (since I open links that require the browser to X out of). It is not satisfactory for IE to handle the popup as default since server authentication is required.

    I have done a lot of the homework above, but I will donate $20 to whoever can figure this out...
    Last edited by jayinthe813; 10-19-2012 at 01:08 PM.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ppDisp to display popup into form2

    I'd have replied to this over at Oz, but I can't post in the Hire section. I also answered you at EE - Hi again

    Honestly, you're flogging a dead horse with this one. Excel VBA <> VB6 it's a stripped back version, all the guides you see out there assume VB5/6, Excel doesn't handle forms in the same way, so when you're using controls on a form that are really designed for use with VB6 you'll find they often lack some of the functionality they offer in a proper environment. As a further example with the webbrowser, you'll notice that you can't put it on a multipage control, when you switch pages and come back, it disappears.

    It's just one of the things you have to work with since you are using controls that were designed for a different environment, some of them work well, others not so well and others not at all

    I suggested Access on EE since the VBA is more rich and far closer to VB6, I think you'll have more luck there - Or maybe you could try VB6, or if you're feeling really adventurous, VB.NET?

  3. #3
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: ppDisp to display popup into form2

    Hello there, and yes I believe you are right on that. Its not really a problem to do it in VB or .net anyhow, but the access functions ive found to be the same as in excel, unless you are looking at something different: It looks as if the VBA engine for excel/access is the same, and that link you provided, the webbrowsercontrol.object will not work in either, so the code is not correct.

    I could write it in vb6, or relearn in .net how to interact with the html object library (since it will be similar syntax anyhow) but it looked like .net web browser control was doing the same thing, but i havnt tried to control popups with it yet. If I could get IE itself to run in a frame that holds it, similar to web browser control, everything would be peachy, I just end up needing an overlay essentially. The IE instances (create application in vba) works fine, its just the web browser control that doesnt like to deal with popups.

    The other alternate way, would be to detect when an onchange event fires and find the location in which it occured, and assign data to a related field, and to do that I think I would need custom classes, not entirely sure on that.
    Last edited by Cutter; 10-17-2012 at 09:26 AM. Reason: Removed whole post quote

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ppDisp to display popup into form2

    VB would be less of a learning curve than .Net, although it looks similar, it's very different, but it would give you a whole load more control.

    Did you try changing .object to .application in access?

    The only thing I can suggest as a work around would be to have the 2nd webbrowser on the same form but off the side of the visible range, then just resize the form so that it is visible.

    Are you talking about trying to catch the javascript onchange event?

  5. #5
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: ppDisp to display popup into form2

    Yes I did try changing it and it didnt work. I tried doing the second web browser on the same form, but once the popup closes, the web browser control closes entirely, so the new window event would need to create the control each time the event happens. As well, the two popups that can occur are: data entry and links. the links dont have a way to "cancel" the popup once clicked, so you cant make them go away without the ability to close. the data entry ones are fired by javascript onchange. Lets say html looks like this:

    Please Login or Register  to view this content.
    This way, I would look for the ID of where the onchange occured (say status0) and I would write the data back to comments0, because the two fields will always be related, e.g. firing onchange on status3 will always write to comments3, and that could be handled by a userform instead, that was the other idea, which would maybe make more sense

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ppDisp to display popup into form2

    new window event would need to create the control each time the event happens
    Have you tried doing that, but creating a new browser on the form each time?

    the links dont have a way to "cancel" the popup once clicked, so you cant make them go away without the ability to close
    If you can get the previous working, you can add a button to close the browser to your form.

    I'd try doing the above before the javascript approach since it's less fiddly

  7. #7
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: ppDisp to display popup into form2

    how would I go about creating a new web browser control each time? I can only find things on creating one inside the spreadsheet

    Please Login or Register  to view this content.

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ppDisp to display popup into form2

    Please Login or Register  to view this content.
    The above works for me, scroll down to one of the links in the thread, the popup opens in the dynamically added browser

    You'll need to add a class to handle events of the created webbrowsers

  9. #9
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: ppDisp to display popup into form2

    You mean to close them? The only issue right now is when I click on a URL to "javascript:openImage()" it opens to the back behind the webbrowser1 control. Otherwise the control works fine.

    If I can figure out some unique identifier, I should be able to test ppDisp with if/then and see if it came from the "javascript:openimage" event, although I cannot do referrer since the domain is static, and just filter it out for now, figure out how to display that later
    Last edited by Cutter; 10-17-2012 at 09:27 AM. Reason: Removed whole post quote

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ppDisp to display popup into form2

    ppDisp is actually nothing, but to understand why that is, you need to understand a bit about how events work.

    Events are raised by procedures like normal functions, in VBA you'd do this with the RaiseEvent statement. These events then create subs in the parent object, so you see:
    Please Login or Register  to view this content.
    So conceptually, what's actually happening within the WebBrowser1 object:
    Please Login or Register  to view this content.
    So the above code raises the event, which manifests in your WebBrowser1_NewWindow2 sub which you then assign values to its parameters e.g
    Please Login or Register  to view this content.
    These values are then passed to the calling sub which raised the event and used in its own code as shown above, it's not massively helpful since you can't check the values of ppDisp since it's nothing, but you can at least understand why.

    You're therefore going to need to figure out a work-around, but I can't really suggest anything since I don't know how the actual new windows are being raised

  11. #11
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: ppDisp to display popup into form2

    since we are creating an instance of explorer shell, is it possible to include something like:

    Please Login or Register  to view this content.
    in order to add a close button (that adds the two others but is for sake of example)

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ppDisp to display popup into form2

    Not for the Webbrowser, you'd need to create a button to close.

    To get the location of a webbrowser:
    Please Login or Register  to view this content.
    You can only use it after the page has navigate so not in your NewWindow2 sub

  13. #13
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: ppDisp to display popup into form2

    Quote Originally Posted by Kyle123 View Post
    Not for the Webbrowser, you'd need to create a button to close.

    To get the location of a webbrowser:
    Please Login or Register  to view this content.
    You can only use it after the page has navigate so not in your NewWindow2 sub
    So I will be unable to test the URL until the page has loaded, which will not do. Right now I set:

    Please Login or Register  to view this content.
    Commandbutton code:

    Please Login or Register  to view this content.
    Say I generate a popup, I dont click the button to close and I let the webpage close the control out, then generate another popup again, the button wont work because it doesnt know how to remove that new control, since it is named different. I think I need to capture the names of the controls thats generating. Do you know how the naming conventions generate?

  14. #14
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ppDisp to display popup into form2

    Since you only ever need one popup, you could loop over all created instances and remove them:
    Module Level
    Please Login or Register  to view this content.
    WebBrowser
    Please Login or Register  to view this content.
    Command Button
    Please Login or Register  to view this content.
    Last edited by Kyle123; 10-19-2012 at 10:45 AM.

  15. #15
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: ppDisp to display popup into form2

    works like a charm! I hope I can gain the knowledge you have one day! Thanks so much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1