0

I have an InfoPath form where I am trying to add a print button and add visual basic to print the form. What I have done so far:

1) Add a button to the form

2) in button properties click edit form code...

3) The code is as follows :

Imports Microsoft.Office.InfoPath
Imports System
Imports System.Xml
Imports System.Xml.XPath


Namespace Performance_and_Development_121_form

    Public Class FormCode

        ' Member variables are not supported in browser-enabled forms.
        ' Instead, write and read these values from the FormState
        ' dictionary using code such as the following:
        '
        ' Private Property _memberVariable() As Object
        '     Get
        '         _memberVariable = FormState("_memberVariable")
        '     End Get
        '     Set
        '         FormState("_memberVariable") = value
        '     End Set
        ' End Property

        ' NOTE: The following procedure is required by Microsoft InfoPath.
        ' It can be modified using Microsoft InfoPath.
        Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup
            AddHandler DirectCast(EventManager.ControlEvents("CTRL97_60"), ButtonEvent).Clicked, AddressOf CTRL97_60_Clicked

            AddHandler DirectCast(EventManager.ControlEvents("PrintForm"), ButtonEvent).Clicked, AddressOf PrintForm_Clicked
        End Sub




        Public Sub PrintForm_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
            XDocument.PrintOut()
        End Sub
    End Class
End Namespace

The only thing I added was XDocument.PrintOut() the rest was generate already. I am getting an error saying XDocument is not declared, this is the same when I add thisXDocument I am using InfoPath 2010 and Visual basic

0

I think you have the answer here:

XDocument is only available in the 2003 object model. In 2007 and 2010, you would use this.Print();

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.