Call ShellExecute(Me.hwnd, "open", "Акт.rtf", "", (App.Path & "\Формуляр\"), 3)
ActiveDocument.SaveAs FileName:="Акт.doc", FileFormat _
:=wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
‘ сохраняет в мои документы
(процедуры заполнения документа)
ActiveDocument.Close
Word.Application.Quit
Set WordApp = New Word.Application
Set WordDoc = WordApp.Documents.Open("C:\1\Акт.doc") ' Word.Application ->WordApp
WordApp.Visible = True
ChangeFileOpenDirectory _
App.Path & "\Акты\"
ActiveDocument.SaveAs FileName:="1.doc", _
FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
WordDoc.Close
WordApp.Quit
Set WordApp = Nothing
Set WordDoc = Nothing
The [appobject] attribute also indicates that the functions and properties of the coclass are globally available in the current type library.
WordApp.visible = false
Поэтому обращайся к функциям ТОЛЬКО через созданные или полученные объекты. Вот это вот "Word.Application ->WordApp" в примере и есть замена обращения глобального объекта на свой, созданный.
Dim WordApp As New Word.Application
Dim WordDoc As Word.Document
On Error GoTo Oshibka
With WordApp
.WindowState = Word.WdWindowState.wdWindowStateNormal
.Documents.Open App.Path & "\Формуляр\Акт.rtf"
Set WordDoc = WordApp.ActiveDocument
.Visible = True
End With
ChangeFileOpenDirectory _
App.Path & "\Акты\"
WordDoc.SaveAs FileName:="Акт №" & Left(Text100.Text, 8) & Mid(Text100.Text, 10, 6) & right(Text100.Text, 5) & ".rtf", _
FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
With WordDoc.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
…
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
With WordApp.Selection
.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Font.Bold = True
.Font.Size = 12
.TypeText Text:="Приложение 1"
…
.Font.Underline = wdUnderlineSingle
.TypeText Text:="" & Trim(Adodc2.Recordset.Fields(5))
End If
End With
WordDoc.Save
WordDoc.Close
WordApp.Quit
Set WordDoc = Nothing
Set WordApp = Nothing
MsgBox "Файл экспортирован в папку Акты", vbInformation, "Информация"
ChangeFileOpenDirectory
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
On Error GoTo Oshibka
Set WordApp = New Word.Application
Set WordDoc = WordApp.Documents.Open(App.Path & "\Формуляр\Акт.rtf")
WordApp.Visible = True
ChangeFileOpenDirectory _
App.Path & "\Акты\"
WordDoc.SaveAs FileName:="Акт №" & Left(Text100.Text, 8) & Mid(Text100.Text, 10, 6) & right(Text100.Text, 5) & ".rtf", _
FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
WordApp.ChangeFileOpenDirectory App.Path & "\Акты\"
Сейчас этот форум просматривают: AhrefsBot и гости: 66