Save and Close Button - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Save and Close Button

Last post 09-19-2013 11:24 PM by larryking123. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 03-14-2010 09:37 AM

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Save and Close Button

    I would like to create a button that saves the form to a specific path and then closes the form.

    Does anybody know how to do this in C#?

    Thanks,

    -Lawson

  • 03-14-2010 10:15 PM In reply to

    this.save("path and location");

    this.close();

    but this does not work for browser enabled forms.

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 03-15-2010 03:43 PM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    I tried this with the following code:

    this.Save_OnClick(@"C:\Users\Lawson\Documents\Saved Forms");

    this.close();

     

    But I got the following errors.

    Error 1-- The best overloaded method match for 'eFileroom_3_13_10.FormCode.Save_OnClick(Microsoft.Office.Interop.InfoPath.SemiTrust.DocActionEvent)' has some invalid arguments           

    Error 2—Argument '1': cannot convert from 'string' to 'Microsoft.Office.Interop.InfoPath.SemiTrust.DocActionEvent'    

    Error 3—'eFileroom_3_13_10.FormCode' does not contain a definition for 'close'

  • 03-15-2010 04:39 PM In reply to

     In InfoPath 2003 code, it would be: 

    this.thisXDocument.SaveAs(@"C:\Users\Lawson\Documents\Saved Forms\" + formName);
    this.thisApplication.Quit(true);

    Above, I've used formName as a placeholder for the form name.  You'll need to come up with a way of uniquely naming the forms.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-16-2010 07:21 AM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

    Thanks Jimmy,

    Can I use the now() function for the formName to uniquely name the form?

    -Lawson

  • 03-16-2010 07:35 AM In reply to

     You can use DateTime.Now.ToString("s") to get the current date and time in the format 2010-03-16T23:34:14, which has a pretty good chance of being unique.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-16-2010 09:34 AM In reply to

    • Lawson
    • Top 100 Contributor
    • Joined on 12-23-2009
    • Virginia
    • Posts 91

     Thanks, I'll try this.

    How can I get the current name of the form and combine it with the DateTime.Now.ToString("s")?

    I think this will give it the best chance at being unique.

    -Lawson

  • 09-19-2013 11:24 PM In reply to

    I looked high and low, trying to figure how to implement this. Dateime.now.tostring("s")

    Took three days of searching and reading, since I am not a VB guru, most of the stuff was hard to understand and bieng on a deadline...  well

    For those that need a nice random filename generator. I give you what it use, it isnot pretty. but if you want to save pdf without over writing previous and not asking use to put in a name

    this will work everytime.

    Here is the code. Hope it helps someone.

      button is pressed it will generate an filename without the :33 which the file systems hates. how to use the system clock to give me a number to append to the filename

    two lines

    Dim

    x As DateTime = Date.Now

    Dim

    x1 As String = x.ToString("-mmss.fff")

    So you filename will be 

    CurrentView.Export(

    "c:\moc\" & WhoamI & "_" & Wrkflw_str & "_" & SCN_str & "_" & Role_str & "_" & Date_str & x1 & ".pdf", ExportFormat.Pdf)

    Notice where x1 is . The output will look like XXXX.2332.543

    enjoy

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