Jump to content

Word.au3 How to delete an empty line?


Recommended Posts

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)
    EndIf

TestDel.zip

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

But this did worked!!! _WordDocFindReplace($oDoc, @CR & "Line 2", "", 1, $oRange)

thank you

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.

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...