Submit button that sends completed form to a network share and also prints the form - InfoPath Dev
in

InfoPath Dev

Submit button that sends completed form to a network share and also prints the form

Last post 03-31-2011 12:53 PM by jambou9182. 23 replies.
Page 1 of 2 (24 items) 1 2 Next >
Sort Posts: Previous Next
  • 10-29-2010 06:31 AM

    Submit button that sends completed form to a network share and also prints the form

    Is it possible to have a submit button that sends the form to a network share and prints out the form onto a networked printer?  I'd like to only have 1 button that does both functions.

  • 10-29-2010 06:57 AM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    Hi Jambou, with codes you can do that with one button :

    this.SaveAs(@"\\YourShare\test.xml");

    this.print();

    with that you're going to save to your share and then print the current view. You have to consider that by default you're going to use the local printer setting (the default one). If you want to change that you can modify the manifest.xsf to set a network printer.

  • 11-08-2010 10:23 AM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    Thanks for your reply.

     I'm new to InfoPath, I'm not sure what to do with your code...

  • 11-08-2010 10:48 AM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    Hi, on Tools, Form option, go under programming and choose C#. after that click on Security and trust, select Full trust and sign the form template.

    Add a button, click on property and select edit form code ...and add my code under the function.

  • 11-10-2010 10:19 AM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    When I add the code I get a build error:

     "Form1.FormCode" does not contain a definition for 'print'

  • 11-10-2010 10:38 AM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    Hi, do you use Infopath Form server or InfoPath rich client ?

  • 11-10-2010 12:46 PM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    I'm using the client, everyone has InfoPath 2010 on their laptops, it's not a browser enabled form.

  • 11-10-2010 01:06 PM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    Can you confirm that in form option, compatibility,  Infopath filler form is selected. You must use this option if you want to use this.print().

  • 11-10-2010 01:29 PM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    ok, I checked, and InfoPath Filler Form is definately selected.

    Here is the form code:

    using Microsoft.Office.InfoPath;
    using System;
    using System.Windows.Forms;
    using System.Xml;
    using System.Xml.XPath;
    using mshtml;

    namespace Form12
    {
        public partial 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 object _memberVariable
            // {
            //     get
            //     {
            //         return FormState["_memberVariable"];
            //     }
            //     set
            //     {
            //         FormState["_memberVariable"] = value;
            //     }
            // }

            // NOTE: The following procedure is required by Microsoft InfoPath.
            // It can be modified using Microsoft InfoPath.
            public void InternalStartup()
            {
                ((ButtonEvent)EventManager.ControlEvents["CTRL3_5"]).Clicked += new ClickedEventHandler(CTRL3_5_Clicked);
            }

            public void CTRL3_5_Clicked(object sender, ClickedEventArgs e)
            {
                this.SaveAs(@"\\ServerName\Share\test.xml");

                this.print();


            }
        }
    }

  • 11-10-2010 01:36 PM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    Hey, I got it to work by capitalizing the "p" in    this.Print();

    Now, is it possible to have the form export to my share in .PDF format?

  • 11-10-2010 04:49 PM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

     Hi, sorry for the "p" of Print().

    The command to do that is :

    this.CurrentView.Export(@"\\SHARE\test.pdf", Microsoft.Office.InfoPath.ExportFormat.Pdf);
     

  • 11-11-2010 05:56 AM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    Awesome that worked!

    Is it possible to export the pdf to the share and also make it print out onto a network printer?

  • 11-11-2010 06:11 AM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    Hi, it's possible, this sample can do it but an adobe viewer window will open at the end of the print, it's exist some other tool without this drawback but it's not free.

    try
                {
                    Process objP = new Process();
                    //open the pdf file
                    objP.StartInfo.FileName = tempFolder + "\\" + Filename;
                    objP.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //Hide the window.
                    objP.StartInfo.Verb = "print";
                    objP.StartInfo.CreateNoWindow = true;//!! Don't create a Window.
                    objP.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    objP.StartInfo.UseShellExecute = true;
                    objP.StartInfo.Arguments = "/t /h \"" + tempFolder + "\\" + Filename;
                    objP.Start();
                    objP.Close();
                }
                catch
                { } 

  • 11-11-2010 06:21 AM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    Hi, thank you for all your help on this, it's greatly appreciated. 

    I get an error at:

    }syntax error, 'try' expected
    catch
    { }

    What is the name of the tool to purchase?

  • 11-11-2010 06:42 AM In reply to

    Re: Submit button that sends completed form to a network share and also prints the form

    Have you insert the"try" in front of the sample of code ?

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