Seite 1 von 1

Apostrophe in Zelle "escapen" - um zu entfernen

Verfasst: Mi, 06.08.2014 17:22
von gigicarlo
Hallo zusammen

klingt einfach - aber ist wohl tricky - ich bekomme es nicht hin.


Hier ein Makro, das ich benutze um einen text so zu formatieren, dass er dann später als gültiger Dateiname taugt.

Was ich nicht hinbekomme, ist das Array so zu erweitern das ein " " " Apostrophe durch einen "_" ersetzt wird.

Habe alle Kombinationen von " und ' und "\" durchprobiert.

geht es einfach nicht ?

Oder weiß jemand einen Ausweg

Danke und Gruß

Luigi

Code: Alles auswählen

Sub fnKHM
oDoc = thisComponent
aFind = Array(" ", "ä" ,"\'", "\+" ,"ö" ,"ü", "-", "\.", "MS", "\(|\)", "ß", "_[0-9]_[0-9][0-9]min", "_+[0-9]+$", "_\&_",  "_\?", "_$", "Nt", "\*|\:", "_{2,}")

aReplace = Array("_", "ae", "", "_und_", "oe", "ue", "_", "_", "_MS_", "", "ss", "", "", "_", "_", "", "NT", "_", "_")   ' just for trying)
'aReplace = Array("១", "២", "៣", "៤", "៥", "៦", "៧", "៨", "៩", "០")

aRayCount = 0

oRange  = oDoc.getCurrentSelection() ' modified by Zizi64
FandR = oRange.createReplaceDescriptor() ' modified by Zizi64

FandR.SearchCaseSensitive = true
FandR.SearchRegularExpression = true


While aRayCount <= uBound(aFind)
FandR.setSearchString(aFind(aRayCount))
FandR.setReplaceString(aReplace(aRayCount))
aRayCount = aRayCount + 1

oRange.ReplaceAll(FandR)  ' modified by Zizi64

Wend
End Sub
Moderation: Zur übersichtlichen Darstellung von Programmcode im Text [​code][​/code] Tags gesetzt.
lorbass, Moderator

Re: Apostrophe in Zelle "escapen" - um zu entfernen

Verfasst: Mi, 06.08.2014 18:01
von Karolus
Hallo
in

Code: Alles auswählen

[code]
-tags[/code] würde dein Code so aussehen:

Code: Alles auswählen

Sub fnKHM
oDoc = thisComponent
aFind = Array(" ", "ä" ,"\'", "\+" ,"ö" ,"ü", "-", "\.", "MS", "\(|\)", "ß", "_[0-9]_[0-9][0-9]min", "_+[0-9]+$", "_\&_", "_\?", "_$", "Nt", "\*|\:", "_{2,}")

aReplace = Array("_", "ae", "", "_und_", "oe", "ue", "_", "_", "_MS_", "", "ss", "", "", "_", "_", "", "NT", "_", "_") ' just for trying)
'aReplace = Array("១", "២", "៣", "៤", "៥", "៦", "៧", "៨", "៩", "០")

aRayCount = 0

oRange = oDoc.getCurrentSelection() ' modified by Zizi64
FandR = oRange.createReplaceDescriptor() ' modified by Zizi64

FandR.SearchCaseSensitive = true
FandR.SearchRegularExpression = true


While aRayCount <= uBound(aFind)
FandR.setSearchString(aFind(aRayCount))
FandR.setReplaceString(aReplace(aRayCount))
aRayCount = aRayCount + 1

oRange.ReplaceAll(FandR) ' modified by Zizi64

Wend
End Sub
Zum Problem:

Code: Alles auswählen

Sub main
Print """"
End Sub
den "while....wend" -block könnte man besser als "for...next" schreiben:

Code: Alles auswählen

...
for i = 0 to uBound(aFind)
FandR.setSearchString(aFind( i ))
FandR.setReplaceString(aReplace( i ))
oRange.ReplaceAll(FandR) ' modified by Karolus ;-)'
next
...
 
Karolus

Re: Apostrophe in Zelle "escapen" - um zu entfernen

Verfasst: Fr, 22.08.2014 14:39
von gigicarlo
Vielen Dank !!!

Das hilft