Button to copy and paste a field on an InfoPath form to the clipboard - InfoPath Dev
in

InfoPath Dev

Button to copy and paste a field on an InfoPath form to the clipboard

Last post 04-27-2009 03:41 PM by msupinski. 20 replies.
Page 2 of 2 (21 items) < Previous 1 2
Sort Posts: Previous Next
  • 02-20-2009 03:08 PM In reply to

    Re: Button to copy and paste a field on an InfoPath form to the clipboard

     This does not appear to work in infopath 2007, any idea on where I can start?

  • 02-20-2009 05:18 PM In reply to

    Re: Button to copy and paste a field on an InfoPath form to the clipboard

    It does work in InfoPath 2007.  Could you show us the code you're trying to use and the error you're getting?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-23-2009 10:38 AM In reply to

    Re: Button to copy and paste a field on an InfoPath form to the clipboard

     I put the code 'as is' after changed event of list box

    Error I'm getting is 'xdocument' is not declared. 


    Namespace NetworkRequestForm2
        Public Class FormCode
            Dim fieldValue As String = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:PatchRequest/@DevName", NamespaceManager).Value

            ' 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 Office InfoPath.
            ' It can be modified using Microsoft Office InfoPath.
            Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup
                AddHandler EventManager.XmlEvents("/dfs:myFields/dfs:dataFields/d:PatchRequest/@New_").Changing, AddressOf PatchRequest_New__attr_Changing
                AddHandler EventManager.XmlEvents("/dfs:myFields/dfs:dataFields/d:PatchRequest/@New_").Validating, AddressOf PatchRequest_New__attr_Validating
                AddHandler EventManager.XmlEvents("/dfs:myFields/dfs:dataFields/d:PatchRequest/@New_").Changed, AddressOf PatchRequest_New__attr_Changed
            End Sub

            Public Sub PatchRequest_New__attr_Changing(ByVal sender As Object, ByVal e As XmlChangingEventArgs)

                ' Ensure that the constraint you are enforcing is compatible
                ' with the default value you set for this XML node.
                Dim fieldValue As String = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:PatchRequest/@DevName", NamespaceManager).Value

            End Sub

            Protected Overrides Sub Finalize()
                MyBase.Finalize()
            End Sub

            Public Sub PatchRequest_New__attr_Validating(ByVal sender As Object, ByVal e As XmlValidatingEventArgs)
                ' Write your code here.
            End Sub

            Public Sub PatchRequest_New__attr_Changed(ByVal sender As Object, ByVal e As XmlEventArgs)
                Dim objXMLNode

                objXMLNode = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:PatchRequest/@DevName")
                XDocument.View.SelectText(objXMLNode)
                XDocument.View.ExecuteAction("Copy")
                ' Write your code here to change the main data source.
            End Sub
        End Class
    End Namespace
    .

  • 02-23-2009 07:55 PM In reply to

    Re: Button to copy and paste a field on an InfoPath form to the clipboard

    That's because it's VBScript code but you're using Visual Basic.  With Visual Basic in InfoPath 2007 you can do this:

    Dim nodeToCopy As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:PatchRequest/@DevName", NamespaceManager)
    If Not String.IsNullOrEmpty(nodeToCopy.Value) Then
         Clipboard.SetText(nodeToCopy.Value, TextDataFormat.Text)
    Else
         MessageBox.Show("There is no text to copy!")
    End If

    That is assuming the field you're referencing is in the main data source.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-24-2009 12:29 PM In reply to

    Re: Button to copy and paste a field on an InfoPath form to the clipboard

    Many Thanks, Correct programming language in of course made a big difference.

     Works great now.

    Now when I open a new form I want the info in the clipboard to paste, but the following command does not work:

    CurrentView.ExecuteAction(ActionType.Paste, "/dfs:myFields/dfs:dataFields/d:Device/@DevName")

     

     

  • 04-27-2009 03:41 PM In reply to

    Re: Button to copy and paste a field on an InfoPath form to the clipboard

    I am trying to use InfoPath 2007 in compatibility mode for 2003.  I want to code on switching view to copy data in field on form to clipboard.  I have tried various ways but keep getting errors.  I feel I am so close and hate to bother you.  What would be the code to use Visual basic InfoPath 2003?  Thanks for your help.

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