Sign in to follow this  
Followers 0
Prozac

Weird ExcelCOM_UDF and character problem

1 post in this topic

#1 ·  Posted (edited)

Hi,

I got a bit of a weird problem.

I have made a script to extract custom properties values out of files using dsofile.dll.

The weird thing, is that when I extract the properties and put them into a excel workbook using ExcelCOM_UDF some of the characters are displayed as another character then the one you see in the custom properties tab of the file.

Example could be the following:

:: Original

CustomProperties.Name = Beskriv

CustomProperties.Value = ø45x65

:: In a text file using FileOpen / FileWriteLinie it will look like this in notepad

Name = Beskriv

Value = ø45x65

:: But in the excel workbook it looks like this

Name = Beskriv

Value = ø45x65

It seems that all danish characters like ÆØÅ and æøå are "converted" to "rubbish", but the really weird think is that I at the same time writes values from a ini file to create the "layout" of the excel workbook, and the danish characters from the ini file, is NOT being "converted", they look as the should.

I use ExcelCOM_UDF to create all entries in the Excel Workbook.

See the below code snippet:

CODE
For $i = 1 to $aFiles[0]

$sCurrentFile = $aFiles[$i]

If StringLen($sCurrentFile) > 35 Then

_InfoTxt("Adding data from: ..." & StringRight($sCurrentFile, 35))

Else

_InfoTxt("Adding data from: " & $sCurrentFile)

EndIf

$sCurrentRow = $i + 1

_ExcelWriteCell($oExcel, $sCurrentFile, $sCurrentRow, 1)

If not FileExists($sCurrentFile) Then

MsgBox(4096, "CustomProperties - ERROR", "Error occurred, Could not find " & $sCurrentFile & @CRLF & "The program will abort.")

Exit

EndIf

$oDocument = $oPropertyReader.GetDocumentProperties($sCurrentFile)

If Not $odocument.IsReadOnly Then

$oCustomProperties = $odocument.CustomProperties

For $ia = 1 to $aFileProperties[0][0]

$sProperty = $aFileProperties[$ia][1]

For $strProperty in $oCustomProperties

If $strProperty.Name = $sProperty Then

_ExcelNumberFormat($oExcel, "@", $sCurrentRow, $ia + 1, $sCurrentRow, $ia + 1)

_ExcelWriteCell($oExcel, $strProperty.Value, $sCurrentRow, $ia + 1) ;<-- This gives ø32x220 for some af the values

$testFile = FileOpen(@ScriptDir & "\test.txt", 1+8)

FileWriteLine($testFile, $strProperty.Value) ;<--- This give ø32x220 for the same values

FileClose($testFile)

EndIf

Next

Next

Else

MsgBox(4096, "CustomProperties - ERROR", "Error occurred, the file : " & @CRLF & $sCurrentFile & @CRLF & " is readonly and will be skipped.")

EndIf

Next

I hope some one can help me find out why this is happening.

Regards

Martin

Edited by Prozac

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0