我创建了这段vb代码,提示用word打开一个特定的文件,修改它,然后将它保存到一个特定的位置。我希望能够在完成后关闭两个窗口,即单词宏文件窗口和保存的文档窗口。
Private Sub Document_Open()
adresse_debut = ActiveDocument.Path
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.InitialView = msoFileDialogViewDetails
.Title = "Select Text File"
.InitialFileName = adresse_debut
.Show
If .SelectedItems.Count = 1 Then
bingo = .SelectedItems(1)
Else
MsgBox ("Error")
Exit Sub
End If
End With
Documents.Open FileName:=bingo
adresse = ActiveDocument.Path & "\"
Nom = ActiveDocument.Name
Nom = Left(Nom, Len(Nom) - 4) & "_Ready.txt"
Selection.TypeParagraph
Selection.TypeText Text:="hello"
ActiveDocument.SaveAs FileName:=adresse & Nom, FileFormat:=wdFormatText
ActiveWindow.Close
End Sub