473,320 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

OLE Document Reader crashes office applications

I am using the DSO OLE Document Properties Reader 2.0 to update custom
properties in office files. (i.e. a word document)

After updating a couple of times, the word document becomes corrupted.

I am using the following code to open the file and update the custom
document properties.

mobjDocument = New DSOFile.OleDocumentPropertiesClass
mobjDocument.Open(FileName, False,
DSOFile.dsoFileOpenOptions.dsoOptionOnlyOpenOLEFil es)
Once the document is opened, update the fields

UpdateData("address1", "1 Homes Palce")
UpdateData("address2", "Reading")
UpdateData("BusinessGroup", "Unknown")

Private Sub UpdateData(ByVal Name As String, ByVal Value As String)

Dim objCustProp As DSOFile.CustomProperty
Dim lngIndex As Long
Dim blnFound As Boolean = False
Dim objValue As Object

Try
For lngIndex = 0 To mobjDocument.CustomProperties.Count - 1
If mobjDocument.CustomProperties(lngIndex).Name = Name Then
objCustProp = mobjDocument.CustomProperties(lngIndex)
objCustProp.Value = Value
blnFound = True
Exit For
End If
Next
Catch ex As Exception
Logging.WriteToSpecifiedFile("Error Finding Data : " &
ex.Message, LogFileName)
End Try

If Not blnFound Then
Try
objValue = CStr(Value)
objCustProp = mobjDocument.CustomProperties.Add(Name,
objValue)
Catch ex1 As Exception
Logging.WriteToSpecifiedFile("Error Adding Data : " &
ex1.Message, LogFileName)
End Try
End If

End Sub
Once the details have been updated, i save the file and close the file

mobjDocument.Save
mobjdocument.Close(True)
mobjDocument = Nothing
The following article says the bug is the product of a very old conflict:
ANSI/Unicode compatibility. but this seems to be appropriate to version 1.4
of the OLE Reader and not 2.0.

http://msdn.microsoft.com/library/de...ui07312001.asp

I basically need to update the word custom properties on a regular basis
without corrupting the office document.



Jul 21 '05 #1
1 1953
Hi,

I found that trying to update or add attributes with empty strings had the
effect that you mention.

"James Hollyhomes" wrote:
I am using the DSO OLE Document Properties Reader 2.0 to update custom
properties in office files. (i.e. a word document)

After updating a couple of times, the word document becomes corrupted.

I am using the following code to open the file and update the custom
document properties.

mobjDocument = New DSOFile.OleDocumentPropertiesClass
mobjDocument.Open(FileName, False,
DSOFile.dsoFileOpenOptions.dsoOptionOnlyOpenOLEFil es)
Once the document is opened, update the fields

UpdateData("address1", "1 Homes Palce")
UpdateData("address2", "Reading")
UpdateData("BusinessGroup", "Unknown")

Private Sub UpdateData(ByVal Name As String, ByVal Value As String)

Dim objCustProp As DSOFile.CustomProperty
Dim lngIndex As Long
Dim blnFound As Boolean = False
Dim objValue As Object

Try
For lngIndex = 0 To mobjDocument.CustomProperties.Count - 1
If mobjDocument.CustomProperties(lngIndex).Name = Name Then
objCustProp = mobjDocument.CustomProperties(lngIndex)
objCustProp.Value = Value
blnFound = True
Exit For
End If
Next
Catch ex As Exception
Logging.WriteToSpecifiedFile("Error Finding Data : " &
ex.Message, LogFileName)
End Try

If Not blnFound Then
Try
objValue = CStr(Value)
objCustProp = mobjDocument.CustomProperties.Add(Name,
objValue)
Catch ex1 As Exception
Logging.WriteToSpecifiedFile("Error Adding Data : " &
ex1.Message, LogFileName)
End Try
End If

End Sub
Once the details have been updated, i save the file and close the file

mobjDocument.Save
mobjdocument.Close(True)
mobjDocument = Nothing
The following article says the bug is the product of a very old conflict:
ANSI/Unicode compatibility. but this seems to be appropriate to version 1.4
of the OLE Reader and not 2.0.

http://msdn.microsoft.com/library/de...ui07312001.asp

I basically need to update the word custom properties on a regular basis
without corrupting the office document.



Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
2
by: Brent | last post by:
I have just installed Office 2003 and Visual Studio Tools for Office 2003, including the Developer Extensions for Access. I kept my Access 2000/MOD installation intact (I hope), installed Access...
8
by: Asma | last post by:
Dear Sir, I am trying to find a way to open a Word document using C language and read the text of word doc into a variable. (Turbo C on Dos 6.0). Can anyone please tell me which libraries in...
2
by: terry | last post by:
I'm trying to figure out how open a microsoft word document from within an asp.net application. There is information in the web form that I need to merge with the opened document. I can't seem to...
1
by: James Hollyhomes | last post by:
I am using the DSO OLE Document Properties Reader 2.0 to update custom properties in office files. (i.e. a word document) After updating a couple of times, the word document becomes corrupted. ...
1
by: K B | last post by:
I'm using the following in .NET to save a Word document to a SQL image column: Dim iImageSize As Integer = FileUpload.PostedFile.ContentLength Dim picbyte() As Byte = New Byte(iImageSize) {}...
9
by: SharpCoderMP | last post by:
i've been experiencing random crashes on some machines running my app. the app never crashed in such way on my dev machine so i'm totally unable to debug this. the error page users get says...
3
by: mnjkahn via AccessMonster.com | last post by:
I'm running Access 2003, modifying a query that has over 45 fields. When I right click on the field name in Query Design View, and then click Build, Access crashes before the Build window...
4
by: stephen | last post by:
Hi all, I am working with Excel. I read an excel document using ExcelReader and lets say it has 10 columns. I have to read each record and based on a specified column peform some activites and...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.