Цитата Chestnut:
1.Название ...просто "Документы", путь сохранения - рабочий стол и папка "Docs" например , с путём я думаю разберусь мне главное выяснить где его прописать, чтобы при закрытии после редактирования не было никаких уточнений - закрыл и документ там. »
|
Цитата Chestnut:
хотя именно удалить мне вручную ctrr+a не затрудняет,так как там много файлов »
|
Речь выше шла о двух документах со строго заданными именами:
Цитата Chestnut:
пара шаблонов - строго прописать в них названия »
|
Не понятно.
Вот Вам пример для одного документа на основе одного шаблона (если Вам действительно нужен документ на основе шаблона, отличного от «Normal.dot»/«Normal.dot»):
читать дальше »
Код:

Option Explicit
Const wdUserTemplatesPath = 2
Const wdDoNotSaveChanges = 0
Dim objFSO
Dim objWshShell
Dim objWord
Dim strTemplateName
Dim strDocumentName
Dim strPath2Save
Dim strPath2Template
Dim strPath2File
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objWshShell = WScript.CreateObject("WScript.Shell")
Set objWord = WScript.CreateObject("Word.Application")
strTemplateName = "My Template.dotx"
strDocumentName = "Документы.docx"
strPath2Save = objFSO.BuildPath(objWshShell.SpecialFolders("Desktop"), "Docs")
With objWord
strPath2Template = objFSO.BuildPath(.Options.DefaultFilePath(wdUserTemplatesPath), strTemplateName)
If objFSO.FileExists(strPath2Template) Then
If objFSO.FolderExists(strPath2Save) Then
strPath2File = objFSO.BuildPath(strPath2Save, strDocumentName)
With .Documents.Add(strPath2Template)
If objFSO.FileExists(strPath2File) Then
objFSO.DeleteFile strPath2File, True
End If
.SaveAs strPath2File
.Close wdDoNotSaveChanges
End With
Else
WScript.Echo "Folder [" & strPath2Save & "] not found"
End If
Else
WScript.Echo "Template [" & strPath2Template & "] not found"
End If
.Quit
End With
Set objWord = Nothing
Set objWshShell = Nothing
Set objFSO = Nothing
WScript.Quit 0
Сохраните приведённый код в файле с расширением «.vbs» в кодировке «ANSI»(«Windows-1251»).
Здесь:
Код:

strTemplateName = "My Template.dotx"
strDocumentName = "Документы.docx"
strPath2Save = objFSO.BuildPath(objWshShell.SpecialFolders("Desktop"), "Docs")
имя заданного шаблона, имя документа и путь к папке для сохранения («Рабочий стол» текущего пользователя +"\Docs») соответственно. Задайте свои данные.
Быть может, для Вас будет удобнее сразу его и открывать?
читать дальше »
Код:

Option Explicit
Const wdUserTemplatesPath = 2
Const wdDoNotSaveChanges = 0
Dim objFSO
Dim objWshShell
Dim objWord
Dim strTemplateName
Dim strDocumentName
Dim strPath2Save
Dim strPath2Template
Dim strPath2File
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objWshShell = WScript.CreateObject("WScript.Shell")
Set objWord = WScript.CreateObject("Word.Application")
strTemplateName = "My Template.dotx"
strDocumentName = "Документы.docx"
strPath2Save = objFSO.BuildPath(objWshShell.SpecialFolders("Desktop"), "Docs")
With objWord
strPath2Template = objFSO.BuildPath(.Options.DefaultFilePath(wdUserTemplatesPath), strTemplateName)
If objFSO.FileExists(strPath2Template) Then
If objFSO.FolderExists(strPath2Save) Then
strPath2File = objFSO.BuildPath(strPath2Save, strDocumentName)
With .Documents.Add(strPath2Template)
If objFSO.FileExists(strPath2File) Then
objFSO.DeleteFile strPath2File, True
End If
.SaveAs strPath2File
.Close wdDoNotSaveChanges
End With
.Documents.Open strPath2File
.Visible = True
Else
WScript.Echo "Folder [" & strPath2Save & "] not found"
.Quit
End If
Else
WScript.Echo "Template [" & strPath2Template & "] not found"
.Quit
End If
End With
Set objWord = Nothing
Set objWshShell = Nothing
Set objFSO = Nothing
WScript.Quit 0