crystalburner Posted October 9, 2006 Share Posted October 9, 2006 Having trubs with this _FindReplace($oDoc, "[firstname]", Chr(171) & "Firstname" & chr (187)) Outputting this "Firstname» Instead of this «Firstname» This doesnt work either $replacementtext = Chr(0x0000AB) & 'Firstname' & Chr(0x0000BB) _FindReplace($oDoc, "[firstname]", $replacementtext) Helppp! Link to comment Share on other sites More sharing options...
i386 Posted October 9, 2006 Share Posted October 9, 2006 If you could post your code here so we can have alittle more idea of what is going on... Unfortantly, not all or any of us are capable of figuring out rocket science. LOL!! Spoiler "...Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like.My crime is that of outsmarting you, something that you will never forgive me for." --The Mentor "Mess with the best, die like the rest!!" -Hackers "This above all to thine own self be true." -William Shakespeare "Corruption is only as corrupted as the individual makes it out to be." -i386 Link to comment Share on other sites More sharing options...
crystalburner Posted October 9, 2006 Author Share Posted October 9, 2006 Thats all the code my man the _findreplace routine in word.au3 Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted October 9, 2006 Moderators Share Posted October 9, 2006 This seems to be a bug in MS Word. Try doing the find/replace operation manually and you will see that you get the same result. Link to comment Share on other sites More sharing options...
crystalburner Posted October 9, 2006 Author Share Posted October 9, 2006 This seems to be a bug in MS Word. Try doing the find/replace operation manually and you will see that you get the same result.Any idea how i can get about it? Link to comment Share on other sites More sharing options...
randallc Posted October 9, 2006 Share Posted October 9, 2006 (edited) Hi, Maybe do a loop; Selection.Find.ClearFormatting With Selection.Find .Text = "[" .Forward = True .Wrap = wdFindContinue End With Selection.Find.Execute Selection.Delete Unit:=wdCharacter, Count:=1 Selection.TypeText Text:="«"Best, Randall EDIT; works now Edited October 9, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
crystalburner Posted October 9, 2006 Author Share Posted October 9, 2006 Hi,Maybe do a loop;Best, RandallEDIT; works nowhummwhere does that go int he code? Link to comment Share on other sites More sharing options...
crystalburner Posted October 9, 2006 Author Share Posted October 9, 2006 hummwhere does that go int he code?RandallC can you write that in autoit?N Link to comment Share on other sites More sharing options...
crystalburner Posted October 9, 2006 Author Share Posted October 9, 2006 heylp! who can save me? Link to comment Share on other sites More sharing options...
crystalburner Posted October 9, 2006 Author Share Posted October 9, 2006 well its been nice talking its a bug in word, some nice man called randall has posted some script from mars i have no idea about (VB?) so thats that then! Link to comment Share on other sites More sharing options...
crystalburner Posted October 9, 2006 Author Share Posted October 9, 2006 Bah! Okay I have to lie down now. I have spent hours sweating blood and I feel dizzy I think this is a good translation of the script from Mars (VB?) but still no joy. If anyone out there knows something it would help save me committing suicide! _FindReplaceChar('[', '«') Func _FindReplaceChar($sCharToReplace, $sChar) Local $oSelection = ObjCreate("Find.ClearFormatting") With $oSelection.Find .Text = $sCharToReplace .Forward = True .Wrap = "wdFindContinue" EndWith $oSelection.Find.Execute $oSelection.Delete("wdCharacter", 1) $oSelection.TypeText($sChar) EndFunc Link to comment Share on other sites More sharing options...
crystalburner Posted October 9, 2006 Author Share Posted October 9, 2006 Bah! Okay I have to lie down now. I have spent hours sweating blood and I feel dizzy I think this is a good translation of the script from Mars (VB?) but still no joy. If anyone out there knows something it would help save me committing suicide! _FindReplaceChar('[', '«') Func _FindReplaceChar($sCharToReplace, $sChar) Local $oSelection = ObjCreate("Find.ClearFormatting") With $oSelection.Find .Text = $sCharToReplace .Forward = True .Wrap = "wdFindContinue" EndWith $oSelection.Find.Execute $oSelection.Delete("wdCharacter", 1) $oSelection.TypeText($sChar) EndFunc Ooops sorry, really for my mistake, that should have been inside code tags. _FindReplaceChar('[', '«') Func _FindReplaceChar($sCharToReplace, $sChar) Local $oSelection = ObjCreate("Find.ClearFormatting") With $oSelection.Find .Text = $sCharToReplace .Forward = True .Wrap = "wdFindContinue" EndWith $oSelection.Find.Execute $oSelection.Delete("wdCharacter", 1) $oSelection.TypeText($sChar) EndFunc Link to comment Share on other sites More sharing options...
randallc Posted October 10, 2006 Share Posted October 10, 2006 (edited) Hi, you will need to use; Global $wdCharacter = 1, $wdExtend = 1, $wdWord = 2, $wdCell = 12, $wdLine = 5, $wdStory = 6, $wdFindContinue = 1 but the func is not yet in a loop, and will only replace one time at present; I am not sure how to get the return values to know how to stop a loop; Best, randall [if i had tim e right now.. sorry] PS - resources; 1. Word forum at Microsoft; near the Excel one;Excel groups 2. try looping using ; If objSelection.Find.Execute Then Wscript.Echo "The search text was found." Else Wscript.Echo "The search text was not found." End If Edited October 10, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
crystalburner Posted October 10, 2006 Author Share Posted October 10, 2006 Hi, you will need to use; Global $wdCharacter = 1, $wdExtend = 1, $wdWord = 2, $wdCell = 12, $wdLine = 5, $wdStory = 6, $wdFindContinue = 1 but the func is not yet in a loop, and will only replace one time at present; I am not sure how to get the return values to know how to stop a loop; Best, randall [if i had tim e right now.. sorry] PS - resources; 1. Word forum at Microsoft; near the Excel one;Excel groups 2. try looping using ; I don't know vbscript/windows script any chance you can speak my language! Link to comment Share on other sites More sharing options...
randallc Posted October 11, 2006 Share Posted October 11, 2006 hi, This works for me; no "save" at present.. ;_FindReplaceChar.au3 #include <Word.au3> $oWordApp = _WordCreate (@ScriptDir & "\Test.doc") $oDoc = _WordDocGetCollection ($oWordApp) Global $wdCharacter = 1, $wdExtend = 1, $wdWord = 2, $wdCell = 12, $wdLine = 5, $wdStory = 6, $wdFindContinue = 1 While _FindReplaceChar($oDoc, '[', '«') WEnd ;_WordQuit ($oWordApp, 0) Func _FindReplaceChar($oDoc, $sCharToReplace, $sChar) $oSelection = $oDoc.application.selection $oSelection.Find.ClearFormatting With $oSelection.Find .Text = $sCharToReplace .Forward = True .Wrap = $wdFindContinue EndWith If $oSelection.Find.Execute Then $oSelection.Delete ($wdCharacter, 1) $oSelection.TypeText ($sChar) ConsoleWrite("return 1"&@LF) Return 1 Else ConsoleWrite("return 0"&@LF) Return 0 EndIf EndFunc ;==>_FindReplaceCharRandall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now