gfunk999 Posted May 2, 2009 Posted May 2, 2009 Hi all, long time no see Does anyone know how to delete an empty line using word object? I'm attaching a TestDel.doc and some simple code of what i'm trying to accomplish. Basically I have three lines Line 1, Line 2, Line3, when I delete Line 2, I would like for Line 3 to shift up one line to eliminate the blank line. #include <word.au3> $sDocPath = @ScriptDir & "\TestDel.doc" $Error = "" $oWordApp = _WordCreate($sDocPath) $oDoc = _WordDocGetCollection($oWordApp, 0) $oRange = $oDoc.Range If $Error = "Errors Found" Then _WordDocFindReplace($oDoc, "Line 1", "Line 1 Replaced", 1, $oRange) _WordDocFindReplace($oDoc, "Line 2", "Line 2 Replaced", 1, $oRange) Else _WordDocFindReplace($oDoc, "Line 2", "", 1, $oRange) EndIfTestDel.zip
Authenticity Posted May 2, 2009 Posted May 2, 2009 _WordDocFindReplace($oDoc, @CRLF & "Line 2", "", 1, $oRange) or _WordDocFindReplace($oDoc, @LF & "Line 2", "", 1, $oRange)
gfunk999 Posted May 2, 2009 Author Posted May 2, 2009 Hi Authenticity,It does not work becuase it's looking for @CRLF or @LF on the same line (prefix), so the string does not match. Did it work for you?Thanks for your reply._WordDocFindReplace($oDoc, @CRLF & "Line 2", "", 1, $oRange)or_WordDocFindReplace($oDoc, @LF & "Line 2", "", 1, $oRange)
gfunk999 Posted May 2, 2009 Author Posted May 2, 2009 But this did worked!!! _WordDocFindReplace($oDoc, @CR & "Line 2", "", 1, $oRange)thank youHi Authenticity,It does not work becuase it's looking for @CRLF or @LF on the same line (prefix), so the string does not match. Did it work for you?Thanks for your reply.
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