Jump to content

Appending text o WORD docuent


Recommended Posts

$Word = ObjCreate("Word.Application")

$Word.Documents.Open(@ScriptDir & "\test.doc")

; code to append a text at the end of the document

; .... code ???

$Word.Activedocument.Save()

;$Word.Activedocument.Close

$Word.quit

$Word=""

Link to comment
Share on other sites

HI,

have a look in the S&S forum. I think bigDaddy made something for that.

Word

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

HI,

have a look in the S&S forum. I think bigDaddy made something for that.

Word

So long,

Mega

A beat Closer :

This code adds text to the document , but at the beginning ....

I want to add to the end of the document ....

Anyone ....with some idea ?

$Word = ObjCreate("Word.Application")

$Word.Documents.Open(@ScriptDir & "\test.doc")

$word.Selection.TypeText( "zip code 123456789 " )

$word.Selection.Font.Bold = True

$word.Selection.TypeText( "" )

$word.Selection.Font.Bold = False

$word.Selection.TypeText( "." )

$Word.Activedocument.Save()

;$Word.Activedocument.Close

$Word.quit

$Word=""

Link to comment
Share on other sites

  • Moderators

As of right now this is the best solution I have.

Requires:

Word.au3 - See my signature for link

#include <Word.au3>

_WordErrorHandlerRegister()

$sFilePath = @ScriptDir & "\test.doc"
$sText1 = "zip code 123456789 "
$sText2 = "."

$oWordApp = _WordCreate($sFilePath)
$oDoc = $oWordApp.ActiveDocument

$oRng1 = $oDoc.Range
$oRng1.InsertAfter ($sText1)
$iEnd = $oRng1.End

$oRng2 = $oDoc.Range($iEnd-StringLen($sText1), $iEnd)
$oRng2.Font.Bold = True
$oRng2.InsertAfter ($sText2)
$iEnd = $oRng2.End

$oRng3 = $oDoc.Range($iEnd-StringLen($sText2), $iEnd)
$oRng2.Font.Bold = False

_WordDocumentSave($oDoc)

_WordQuit($oWordApp)
Link to comment
Share on other sites

As of right now this is the best solution I have.

Requires:

Word.au3 - See my signature for link

#include <Word.au3>

_WordErrorHandlerRegister()

$sFilePath = @ScriptDir & "\test.doc"
$sText1 = "zip code 123456789 "
$sText2 = "."

$oWordApp = _WordCreate($sFilePath)
$oDoc = $oWordApp.ActiveDocument

$oRng1 = $oDoc.Range
$oRng1.InsertAfter ($sText1)
$iEnd = $oRng1.End

$oRng2 = $oDoc.Range($iEnd-StringLen($sText1), $iEnd)
$oRng2.Font.Bold = True
$oRng2.InsertAfter ($sText2)
$iEnd = $oRng2.End

$oRng3 = $oDoc.Range($iEnd-StringLen($sText2), $iEnd)
$oRng2.Font.Bold = False

_WordDocumentSave($oDoc)

_WordQuit($oWordApp)

Thanks Big Daddy !

it works !

How can i do it with silent mode ? without opening word ?

Yours Library are excellent which i did not know existed .

I hope you will complete everything .

Link to comment
Share on other sites

  • Moderators

Thanks Big Daddy !

it works !

How can i do it with silent mode ? without opening word ?

Yours Library are excellent which i did not know existed .

I hope you will complete everything .

You still have to open word, but you can open it hidden.

Change:

$oWordApp = _WordCreate($sFilePath)oÝ÷ Ù:ºÚ"µÍÌÍÛÕÛÜHÕÛÜÜX]J   ÌÍÜÑ[T]
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...