Jump to content

Big Daddy Word.au3


Recommended Posts

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

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

 

style7,AutoIt.png

 

 

Link to comment
Share on other sites

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 by randallc
Link to comment
Share on other sites

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

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

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 by randallc
Link to comment
Share on other sites

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

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   ;==>_FindReplaceChar
Randall
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...