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 2 of 2 (24 items) < Previous 1 2
Sort Posts: Previous Next
  • 11-11-2010 06:48 AM In reply to

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

    I added the try infront of the code, I get a few errors:

    The type or namespace name 'Process' could not be found (are you missing a using directive or an assembly reference?) 
    The name 'tempFolder' does not exist in the current context
    The name 'Filename' does not exist in the current context
    The name 'ProcessWindowStyle' does not exist in the current context

     

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

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

    Ok, add this namespace in front of the code :

    using System.Diagnostics;

    For  'tempFolder' and 'Filename', you have to replace that by your own path and filename.

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

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

    It doesn't like when I change the values of 'tempFolder' and 'Filename'

    If I use:

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

    Is it possible to pull the filename from a field value in the form or maybe todays date and time instead of using 'test' ?

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

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

    Hi, Yes you can use a field value instead of 'tempFolder' and 'Filename'

    I update the code to fit with 'test.pdf'.

                try
                {
                    Process objP = new Process();
                    //open the pdf file
                    objP.StartInfo.FileName = @"\\SHARE\test.pdf";
                    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 \""+"\\SHARE\test.pdf";
                    objP.Start();
                    objP.Close();
                }
                catch
                { } 

  • 11-11-2010 01:40 PM In reply to

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

    Hi ,

    So if I want to use a field in my form called "Lastname" with a value of "Smith", how can I force the form to automatically replace "test.pdf" with "Smith.pdf" ?

  • 11-11-2010 03:51 PM In reply to

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

     Hi, for that you can use:

               string Filename = this.MainDataSource.CreateNavigator().SelectSingleNode("Xpath", this.NamespaceManager).Value;


    You have to replace Xpath by your own for that right click on your field on"Data source" and click copy Xpath, after at you paste it in the code.

     After that, you have to replace all your hardcoded path like:

    this.SaveAs(@"\\ServerName\Share\test.xml");

    by

    this.SaveAs(@"\\ServerName\Share\" + Filename + ".xml");

  • 11-15-2010 07:51 AM In reply to

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

    Using the export to PDF...how do I use the field name instead of test.pdf

    Here is my code:

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

    How can I change the exported file name to automatically use a field in my form called Fullname?  So say my field name value is Jane Smith, can I make the form be named Jane Smith.pdf?

  • 11-15-2010 10:09 AM In reply to

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

    I got it to work:

    string Filename = this.MainDataSource.CreateNavigator().SelectSingleNode("/my:BaseTemplateFields/my:FullName", this.NamespaceManager).Value;
                this.CurrentView.Export(@"\\Sharename\Folder\" + Filename + ".pdf", Microsoft.Office.InfoPath.ExportFormat.Pdf);

     

    Thanks again for all your help!.

  • 03-31-2011 12:53 PM In reply to

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

    Is there a way I can have this form submit as a PDF document to a SharePoint library instead of a network share?

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