Setting Save As default location with OnSaveRequest - InfoPath Dev
in

InfoPath Dev

Setting Save As default location with OnSaveRequest

Last post 12-06-2011 06:48 AM by Kear777. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 12-06-2011 01:45 AM

    Setting Save As default location with OnSaveRequest

    Morning all!

    I am trying to create an OnSaveRequest event that sets the SaveAs default location. This is what I have so far.

    Sub XDocument_OnSaveRequest(eventObj)
         If evenObj.IsSaveAs = True then
              XDocument.UI.SetSaveAsDialogLocation("C:\")
              XDocument.UI.SetSaveAsDialogFileName("form1")
         End If
         eventObj.isCancelled = eventObj.performsaveoperation()
         eventobj.returnstatus = true
    End Sub

    When trying to save I'm getting the following error

    "The OnSaveRequest function returned a value indicating that the save failed"

     Any ideas?

    K

    Filed under: , ,
  • 12-06-2011 05:33 AM In reply to

    Re: Setting Save As default location with OnSaveRequest

    I suggest checking the capitalization on isCancelled, performsaveoperatoin, and returnstatus.  I reckon those are case sensitive.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-06-2011 05:54 AM In reply to

    Re: Setting Save As default location with OnSaveRequest

    Thanks for the response.

    I don't think it's a case sensitivity issue. I should of mentioned before but it seems to be error seems to be comming from the two lines below

    XDocument.UI.SetSaveAsDialogLocation("C:\")
    XDocument.UI.SetSaveAsDialogFileName("form1")

  • 12-06-2011 06:48 AM In reply to

    Re: Setting Save As default location with OnSaveRequest

    Well that was stupid I didn't notice the typo on the If statement (evenObj).

    If anyone's interested this is the complete code with a couple of extra lines so it does exactly what I want it to do.

    Sub XDocument_OnSaveRequest(eventObj)
         ' Write the code to be run before saving here.
         If xdocument.view.name <> "Read Only" and xdocument.view.name <> "Unavailable" _
         and xdocument.view.name <> "Access Denied" then
             
              if eventObj.IsSaveAs = True then
                   XDocument.UI.SetSaveAsDialogLocation("C:\")
                   XDocument.UI.SetSaveAsDialogFileName("form1")
              End If

              eventObj.IsCancelled = eventObj.PerformSaveOperation

         Else
              msgbox "You do not have permission to save this document.",vbOKOnly,"Save Failed"
         End If 

         ' Write the code to be run after saving here.
         eventObj.ReturnStatus = True
    End Sub

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