Есть ли в MS Word batch mode?
---
"...Я в своём гамаке хочу полноценно трахаться на лыжах."
С помощью WSH, я думаю, можно замутить такое дело.
Или в дистрибутиве есть документация,
в которой ясно указано, что надо вызвать?
---
Q21: что такое Win2k?
A21: состема.
У Word-а свой апи. WSH - один из простых способов до него добраться. Если даже бы не было апи, то всш-ем ты можешь жать на кнопки интерфейса и замутить доступ к "апи" таким макаром.
Где в дистрибутиве лежит актуальная документация?
> WSH - один из простых способов до него добраться.
Ничего хорошего не ожидалось.
Где документация?
> Если даже бы не было апи, то всш-ем ты можешь жать на кнопки интерфейса
Да, я помню, как устроено мышление виндузятников.
DarkGray рассказывал.
---
Q21: что такое Win2k?
A21: состема.
Я не доказывать тебе что-то собрался. Если бы не спала женщина, включил бы свет, открыл бы книгу и дал более конретный ответ. Сомневаюсь, что в дистре ворда есть нормальная документация на эту тему. Думаю, поможет МСДН.
Working with Document Objects
In Visual Basic, the methods for modifying files are methods of the Document
object or the Documents collection object. This topic includes Visual Basic
examples related to the following tasks:
Creating a new document
Opening a document
Saving an existing document
Saving a new document
Activating a document
Determining if a document is open
Referring to the active document
Creating a new document
The Documents collection includes all of the open documents. To create a new
document, use the Add method to add a Document object to the Documents
collection. The following instruction creates a new document.
Documents.Add
A better way to create a new document is to assign the return value to an
object variable. The Add method returns a Document object that refers to the
new document. In the following example, the Document object returned by the Add
method is assigned to an object variable. Then several properties and methods
of the Document object are set. You can easily control the new document using
an object variable.
Sub NewSampleDoc
Dim docNew As Document
Set docNew = Documents.Add
With docNew
.Content.Font.Name = "Tahoma"
.SaveAs FileName:="Sample.doc"
End With
End Sub
Opening a document
To open an existing document, use the Open method with the Documents
collection. The following instruction opens a document named Sample.doc located
in the MyFolder folder.
Sub OpenDocument
Documents.Open FileName:="C:\MyFolder\Sample.doc"
End Sub
Saving an existing document
To save a single document, use the Save method with the Document object. The
following instruction saves the document named Sales.doc.
Sub SaveDocument
Documents("Sales.doc").Save
End Sub
You can save all open documents by applying the Save method to the Documents
collection. The following instruction saves all open documents.
Sub SaveAllOpenDocuments
Documents.Save
End Sub
Saving a new document
To save a single document, use the SaveAs method with a Document object. The
following instruction saves the active document as "Temp.doc" in the current
folder.
Sub SaveNewDocument
ActiveDocument.SaveAs FileName:="Temp.doc"
End Sub
The FileName argument can include only the file name or the complete path (for
example, "C:\Documents\Temporary File.doc").
Closing documents
To close a single document, use the Close method with a Document object. The
following instruction closes and saves the document named Sales.doc.
Sub CloseDocument
Documents("Sales.doc").Close SaveChanges:=wdSaveChanges
End Sub
You can close all open documents by applying the Close method to the Documents
collection. The following instruction closes all documents without saving
changes.
Sub CloseAllDocuments
Documents.Close SaveChanges:=wdDoNotSaveChanges
End Sub
The following example prompts the user to save each document before the
document is closed.
Sub PromptToSaveAndClose
Dim doc As Document
For Each doc In Documents
doc.Close SaveChanges:=wdPromptToSaveChanges
Next
End Sub
Activating a document
To change the active document, use the Activate method with a Document object.
The following instruction activates the open document named Sales.doc.
Sub ActivateDocument
Documents("Sales.doc").Activate
End Sub
Determining if a document is open
To determine if a document is open, you can enumerate the Documents collection
by using a For Each...Next statement. The following example activates the
document named Sample.doc if the document is open, or opens Sample.doc if it's
not currently open.
Sub ActivateOrOpenDocument
Dim doc As Document
Dim docFound As Boolean
For Each doc In Documents
If InStr(1, doc.Name, "sample.doc", 1) Then
doc.Activate
docFound = True
Exit For
Else
docFound = False
End If
Next doc
If docFound = False Then Documents.Open FileName:="Sample.doc"
End Sub
Referring to the active document
Instead of referring to a document by name or index number — for example
Documents("Sales.doc") — the ActiveDocument property returns a Document object
which refers to the active document (the document with the focus). The
following example displays the name of the active document, or if there are no
documents open, it displays a message.
Sub ActiveDocumentName
If Documents.Count >= 1 Then
MsgBox ActiveDocument.Name
Else
MsgBox "No documents are open"
End If
End Sub
See Also | Working with Range Objects | Working with the Selection Object
©2003
Из приведённого кода не видно, который вызывается интерпретатор.
Нужен MS Word, а не что-то произвольное.
Он определяется автомагически?
Как он определяется?
Если по расширению файла, то как вынудить его принимать другие расширения?
Создавать ещё одну копию файла?
Или копию файла всё равно надо создавать, а не то попортит?
---
Q21: что такое Win2k?
A21: состема.
Он существует в кусках?
---
Q21: что такое Win2k?
A21: состема.
Вот последняя ссылка похожа на что-то полезное.
---
Q21: что такое Win2k?
A21: состема.
![](/images/graemlins/smile.gif)
У меня не было конвертера в Word 97, поэтому сохраняется просто plain text. Соответственно, чтобы сохранять в формате Word 97, надо как-то менять параметр FileFormat.
Получилось так:
Sub conv
With Application.FileSearch
.NewSearch
.LookIn = "C:\temp"
.FileName = "*.rtf"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
file_ed = .FoundFiles(i)
Documents.Open (file_ed)
Documents(file_ed).Activate
ActiveDocument.SaveAs FileName:=file_ed + ".txt", FileFormat:=wdFormatText
ActiveDocument.Close
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub
что отчётливо ясно, что надо сделать с приложенным кодом.
Виндузятники же о пользователях не подумали нисколько.
Не говоря уже о том, что примеры расчитаны непонятно на кого.
Такое впечатление, будто виндузятники так и остались в середине восьмидесятых.
---
Q21: что такое Win2k?
A21: состема.
Хочешь по человечески, воспользуйся msdn, она в полном виде есть онлайн.
Советую либо полностью перейти на твою Лучшую-в-мире-операционную-систему, либо перестать скулить.
Зато нисколько не удивительно, что никто не предложил решения, основанного на яве.
---
"Мы диалектику учили не по Гегелю."
Сомневаюсь, что в дистре ворда есть нормальная документация на эту тему.О, Господи... Из Type Library извлекаются заголовки для интерфейсов, оформленные на каком-либо языке программирования. Учитывая то, что там все названия говорят сами за себя, их почти достаточно. Ну можно еще добавить умение ворда запускать макросы....
Кстати, именно макросов будет более чем достаточно для решения поставленной задачи.
Зато нисколько не удивительно, что никто не предложил решения, основанного на яве.предложи.
Средства автоматизации в оффисе есть, при чем встроенные.
Виндузятники же о пользователях не подумали нисколько.Вот с этого места все начинают громко ржать.
Она в FAQ этого раздела уже очень давно.
Оставить комментарий
Ivan8209
Интересует возможность использовать его в качестве конвертера RTF --> MS Word '97 из CygWin.---
Q21: что такое Win2k?
A21: состема.