D
Dazza
I am changing Document Custom Properties via my VB.NET code (see below) but when I perform the save on the document, word doesn't seem to recognise my changes and doesn't save the document ( i.e the date/time modified doesn't change and my alterations aren't applied ). I have checked the properties just before doing the save and they are as they should be. When the save is run it doesn't throw any exceptions.
When I do the same change manually everything works as it should.
I have also tried iDocument.Close(SaveChanges:=wdSaveChanges) and this doesn't force the changes to be saved. I have done similar code before on Word 2000 and it seemed to have no problems. Does anyone know how to touch the document so Word thinks it has been changed, without altering any of the content
Private iWordApplication As Objec
Public Sub SetDocProperties(ByVal pDoc As String, ByVal pProperties As Collection
Dim iDocument As Objec
Dim iDocProperty As DocPropert
' Open the Word documen
iDocument = iWordApplication.Documents.Open(pDoc
' Process every property in the properties collectio
For Each iDocProperty In pPropertie
' Determine if the property is a system property or a custom property. Call the appropriate subroutine
If isSystemProperty(iDocProperty.PropertyName) The
SetSystemProperty(iDocument, iDocProperty.PropertyName, ""
SetSystemProperty(iDocument, iDocProperty.PropertyName, iDocProperty.PropertyValue
Els
SetCustomProperty(iDocument, iDocProperty.PropertyName, ""
SetCustomProperty(iDocument, iDocProperty.PropertyName, iDocProperty.PropertyValue
End I
Next iDocPropert
' Save the word document and close it
iDocument.save(
iDocument.Close(SaveChanges:=0
iDocument = Nothin
End Sub
When I do the same change manually everything works as it should.
I have also tried iDocument.Close(SaveChanges:=wdSaveChanges) and this doesn't force the changes to be saved. I have done similar code before on Word 2000 and it seemed to have no problems. Does anyone know how to touch the document so Word thinks it has been changed, without altering any of the content
Private iWordApplication As Objec
Public Sub SetDocProperties(ByVal pDoc As String, ByVal pProperties As Collection
Dim iDocument As Objec
Dim iDocProperty As DocPropert
' Open the Word documen
iDocument = iWordApplication.Documents.Open(pDoc
' Process every property in the properties collectio
For Each iDocProperty In pPropertie
' Determine if the property is a system property or a custom property. Call the appropriate subroutine
If isSystemProperty(iDocProperty.PropertyName) The
SetSystemProperty(iDocument, iDocProperty.PropertyName, ""
SetSystemProperty(iDocument, iDocProperty.PropertyName, iDocProperty.PropertyValue
Els
SetCustomProperty(iDocument, iDocProperty.PropertyName, ""
SetCustomProperty(iDocument, iDocProperty.PropertyName, iDocProperty.PropertyValue
End I
Next iDocPropert
' Save the word document and close it
iDocument.save(
iDocument.Close(SaveChanges:=0
iDocument = Nothin
End Sub