Only just started dabbling with InfoPath. I am currently designing a form that needs to be saved to a specific location with a specific reference id as the file name which is to be taken from a field within the form. But alas, as you might have guessed, it does not work for me.
I have followed steps outlined in the article Extending the Save Functionality in InfoPath 2003
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ip2003_ta/html/odc_InfoPath_extending_save.aspThis document describes how to add script through Tools - Form Options > Open And Save > Save Behaviour > Save using custom code
The code I have used is as follows:
Sub XDocument_OnSaveRequest(eventObj)
' Write the code to be run before saving here.
Dim GMSRef
GMSRef = thisXDocument.DOM.selectSingleNode("//my:myfields/my:field5").text
If thisXDocument.IsNew = True or eventObj.IsSaveAs = False then
If eventObj.IsSaveAs = True then
thisXDocument.UI.SetSaveAsDialogLocation("f:\Windows Infrastructure\Inspection Form")
thisXDocument.UI.SetSaveAsDialogFileName(GMSRef)
End If
eventObj.IsCancelled = eventObj.PerformSaveOperation()
eventObj.ReturnStatus = true
Else
thisXDocument.UI.Alert("The 'Save As' functionality is disabled for forms that are not new.")
End If
End Sub
The error message is as follows:
quote:
InfoPath cannot save the form.
The OnSaveRequest function returned a value indicating that the save failed.
The following error occurred.
Object required: 'thisXDocument'
File:script.vbs
Line 24
Line 24 is highlighted red and bold.
Any help would be gratefully recieved. I know I am doing something daft and it is most likely to do with the way I am using vb.
Thanks