opening an external URL from VB code (infopath 2010) - InfoPath Dev
in

InfoPath Dev

opening an external URL from VB code (infopath 2010)

Last post 01-13-2012 02:27 AM by paolo. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 01-09-2012 04:06 AM

    • paolo
    • Not Ranked
    • Joined on 11-25-2011
    • Posts 20

    opening an external URL from VB code (infopath 2010)

    Hallo,

    I would like to open an external URL in IE from infopath 2010 using VB code.

    I looked here for a solution, and found a post with a javascript solution, which is

    not applicable to infopath 2010. Therefore I am posting again.

    I would like to find a VB way of doing it.

    Basically, I just need to spawn an Internet Explorer session with a give URL from

    my infopath form. Any suggestion is appreciated. I know how to place code in the

    right spot, just need the command to spawn IE or open an URL.

     

    Thanks,

    Paolo Grigis

    ABB Switzerland 

     

     

     

     

  • 01-09-2012 11:34 PM In reply to

    • paolo
    • Not Ranked
    • Joined on 11-25-2011
    • Posts 20

    Re: opening an external URL from VB code (infopath 2010)

     Well, I am going to list here what I tried (and failed).

    1) code:

    Dim Explorer As Object
    Set Explorer = CreateObject("InternetExplorer.Application")

     fails with error: Name ' Create Object' is not declared

    2) code:

     System.Diagnostics.Process.Start("iexplore.exe","www.google.com")

     fails with a System.Security.SecurityException error.

    3) code:

     Microsoft.VisualBasic.Interaction.Shell("iexplore.exe")

     fails triggering a security exception.


     Will update here as I try more option and state whether they succeed or fail...

  • 01-10-2012 02:41 AM In reply to

    Re: opening an external URL from VB code (infopath 2010)

    Hi Paolo,

    qRules contains a command that does this. If nobody replies with code advice, you could install the free trial and use that command. We'd be more than happy to share the code for it (it's written in C#); maybe Hilary or Jimmy will respond with that ...

    Patrick Halstead
    Project Manager at Qdabra
  • 01-10-2012 02:48 AM In reply to

    Re: opening an external URL from VB code (infopath 2010)

    Approach 2 should work, and I reckon 3 would too.  The issue is that anything as invasive as starting other processes is going to require your form to be full trust (that's what those SecurityExceptions mean).  Please try again after setting your form to full trust.

    You can also have windows open the url in the default browser by using Process.Start(url), but that will require full trust just the same.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-10-2012 06:09 AM In reply to

    • paolo
    • Not Ranked
    • Joined on 11-25-2011
    • Posts 20

    Re: opening an external URL from VB code (infopath 2010)

     Thanks for your reply...  that's what I was afraid of.

    When I set the form for full trust, I will need to install a security certificate or digitally sign the form.

    This is not something I am very familiar with, so before I start, I have a few general questions.

    In the case where I have several form, running on different computers and different users,

    will I need to provide a different certificate for every form or for every machine or user?

    Or will one certificate be enough to cover all the forms on different machines and users?

    Thanks,

    Paolo

     

     

     

     

  • 01-13-2012 02:27 AM In reply to

    • paolo
    • Not Ranked
    • Joined on 11-25-2011
    • Posts 20

    Re: opening an external URL from VB code (infopath 2010)

     OK, let me explain what I did for future reference.

    I managed to make this work with self-generated certificates. Obviously this

    is not optimal, but is a solution I could implement right away...  Hope this may

    be helpful for someone in the future.

     

    I generated a certificate using the "Digital Certificate for VBA Projects" applications

    from Office 2010. That would generate a certificate that is valid for 6 years but is

    only recognized by the machine where is generated. I created my form template

    using this certificate and exported the form. I would then go to the machine where

    I need the form to run and open the exported form. I get a security warning message,

    and from there i would click on the link to view the certificate, examine the details and

    look for the "export certificate" button. Clicking that opens a wizard - on the second

    page I selected as the destination for the export "Trusted Root Certification Authorities".

    Next time I open the form, the security warning comes up again, and now I can click

    on "trust all documents from this publisher". Done - from now on it works with no

    security warning and the form runs as full trust. Just repeats this for every machine

    where the forms need to run.

     

     

     

Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.