How to create a print button in C# or VB? - InfoPath Dev
in

InfoPath Dev

How to create a print button in C# or VB?

Last post 11-28-2007 10:02 AM by Zekebark. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 11-27-2007 06:46 PM

    How to create a print button in C# or VB?

    Hi, first time poster, new to Infopath.

     
    I'm not really a programmer but I understand that it will take managed code (C# or VB) if I'd like to create a print button on a fully trusted browser based form. I decided to take a crack at this with VB (since I was able to achieve this with VBScript) using the code below:

    Public Sub CTRL110_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
                thisXDocument.PrintOut()
            End Sub

     this results in an error stating that "thisXDocument" is not declared. Any C# or VB solution for this would make my week!

     
     

  • 11-27-2007 06:56 PM In reply to

    Re: How to create a print button in C# or VB?

     This is using Infopath 2007 btw

     (also, probably should have posted this in the code forum...oops!)
     

  • 11-27-2007 10:27 PM In reply to

    Re: How to create a print button in C# or VB?

    Hi Zekebark and welcome to our forum!

    Here's an excerpt from Chapter 2 of my book. Note: this does not use the InfoPath 2007 object model.

    Imports System
    Imports Microsoft.Office.Interop.InfoPath.SemiTrust
    Imports Microsoft.VisualBasic

    ' Office integration attribute. Identifies the startup class for the form. Do not
    ' modify.
    <Assembly: System.ComponentModel.DescriptionAttribute("InfoPathStartupClass, Version=1.0, Class=Hello_World.Hello_World ")>

    Namespace Hello_World

        ' The namespace prefixes defined in this attribute must remain synchronized with
        ' those in the form definition file (.xsf).
        <InfoPathNamespace("xmlns:my='http://schemas.microsoft.com/office/infopath/2003/myXSD/2004-02-07T05-55-01'")> _
        Public Class Hello_World

            Private thisXDocument As XDocument
            Private thisApplication As Application

            Public Sub _Startup (app As Application, doc As XDocument)
                thisXDocument = doc
                thisApplication = app

                ' You can add additional initialization code here.
            End Sub

            Public Sub _Shutdown ()
            End Sub

        End Class

    End Namespace

    Patrick Halstead
    Project Manager at Qdabra
  • 11-28-2007 10:02 AM In reply to

    Re: How to create a print button in C# or VB?

     Hi Patrick, thanks for the response! I'll have to look into getting a copy of the book :)

    Unfortunately, my requirements dictate that I must use Infopath 2007. It's probably over my head, but I'll try to investigate the IP 07 Object model and see if  I can get it to work using this as a start. I'll post my results here if I have any luck.

     thanks!

    -Z
     

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