打开关闭保存为Word文件本程序打开在预定的位置,并保存Word文件与其他文件的名称到另一个地方。
解释为了使该方案的工作参考“Microsoft Word的XX.X对象库”需要启用。 作者代码示例文件可能下载于本网站年底,享用!或者只要复制并粘贴此网页的代码直接。
码Sub Open_Close_Save_As_Word_File()
Dim Open_Close_Save_As_Word_File_APP As Word.Application Dim Open_Close_Save_As_Word_File_DOC As Word.Document Set Open_Close_Save_As_Word_File_APP = CreateObject("Word.Application")
Dim PlaceOfWordFile As String Dim NameOfWordFile As String Dim NewPlaceOfWordFile As String Dim NewNameOfWordFile As String
PlaceOfWordFile = Range("B4").Value NameOfWordFile = Range("B5").Value NewPlaceOfWordFile = Range("B6").Value NewNameOfWordFile = Range("B7").Value
NamePlace = PlaceOfWordFile + "\" + NameOfWordFile NewNamePlace = NewPlaceOfWordFile + "\" + NewNameOfWordFile
Open_Close_Save_As_Word_File_APP.Visible = True Set Open_Close_Save_As_Word_File_DOC = Open_Close_Save_As_Word_File_APP.Documents.Open(NamePlace, ReadOnly:=True)
Open_Close_Save_As_Word_File_DOC.SaveAs (NewNamePlace) Open_Close_Save_As_Word_File_APP.Quit
Set Open_Close_Save_As_Word_File_DOC = Nothing Set Open_Close_Save_As_Word_File_APP = Nothing
End Sub
下载Excel文件!Open_Close_Save_As_Word_File.xls |