Adding a print button in InfoPath - InfoPath Dev
in

InfoPath Dev

Adding a print button in InfoPath

Last post 09-17-2015 02:38 PM by jefeW. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 09-09-2015 02:55 PM

    • jefeW
    • Not Ranked
    • Joined on 09-09-2015
    • Posts 4

    Adding a print button in InfoPath

    I'm trying to add an InfoPath button (similar to submit button) at the end of my form.  I'll admit I'm not the best with C# but I added the code below.  But it gives the error "Expression Expected" when I include the 2 "using namespace" lines.  Any help on this error or other ways to add a simple Print button would be appreciated.  (FYI, this is not published to SharePoint, just a stand alone form.)

     

     

    Public Sub btn_print_form_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

    using namespace System.Drawing;

    using namespace System.Drawing.Printing;


                               this.print()

    End Using

    End Using

    End Sub

     

  • 09-16-2015 04:15 PM In reply to

    Re: Adding a print button in InfoPath

    This appears to be VB, sort of, not C#. I don't think you need your "using" namespaces. I'd just get rid of the using / end using and replace "this.print()" with "Me.Print()" (https://msdn.microsoft.com/en-us/library/office/Aa944006.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2)
    Hilary Stoupa

  • 09-17-2015 07:35 AM In reply to

    • jefeW
    • Not Ranked
    • Joined on 09-09-2015
    • Posts 4

    Re: Adding a print button in InfoPath

     Thanks for the response. I actually tried going with the simple 'me.print()' but it gives the following error: 'print' is not a member of 'TestForm.FormCode'.  I included those namespaces because it seemed like I did not have access to any print functionality.  Here's the entire code for my form.  This is really the first thing that I've tried adding.

     

    Imports Microsoft.Office.InfoPath

    Imports System

    Imports System.Xml

    Imports System.Xml.XPath


    Namespace TestForm

    Public Class FormCode

    Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup

    AddHandler DirectCast(EventManager.ControlEvents("btn_print_form"), ButtonEvent).Clicked, AddressOf btn_print_form_Clicked

    End Sub

    Public Sub btn_print_form_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

      Me.print()

    End Sub

    End Class

    End Namespace

     

    Filed under:
  • 09-17-2015 09:47 AM In reply to

    Re: Adding a print button in InfoPath

    Make sure your form is a filler form and it has to be full trust.
    Hilary Stoupa

  • 09-17-2015 02:38 PM In reply to

    • jefeW
    • Not Ranked
    • Joined on 09-09-2015
    • Posts 4

    Re: Adding a print button in InfoPath

     Thanks, that was it.  Needed to set it to Full Trust.

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