Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Скриптовые языки администрирования Windows (http://forum.oszone.net/forumdisplay.php?f=102)
-   -   [решено] Вставить строки в конце файла WORD (http://forum.oszone.net/showthread.php?t=239422)

AlexVong 26-07-2012 22:07 1959567

Вставить строки в конце файла WORD
 
Как при помощи vbs вставить текст (несколько строк) в конце существующего текста в файле MS WORD?

Iska 27-07-2012 00:33 1959680

Примерно так:
читать дальше »
Код:

Option Explicit

Dim strPath2Document
Dim strText


strPath2Document = "E:\Песочница\0163\Hello World.doc"
strText          = _
        "Мама мыла раму" & vbCrLf & _
        "Рабы не мы. Мы не рабы." & vbCrLf

If WScript.CreateObject("Scripting.FileSystemObject").FileExists(strPath2Document) Then
        With WScript.CreateObject("Word.Application")
                With .Documents.Open(strPath2Document)
                        .Content.InsertAfter(strText)
                        .Save
                        .Close
                End With
               
                .Quit
        End With
Else
        WScript.Echo "Document [" & strPath2Document & "] not found"
        WScript.Quit 1
End If

WScript.Quit 0



Время: 15:42.

Время: 15:42.
© OSzone.net 2001-