我想用VB编一个程序,运行以后,只要打开任何doc-exl-ppt文件,都自动保存到指定文件夹,不需要什么程序界面美观。。。。
我想用VB编一个程序,运行以后,只要打开任何doc-exl-ppt文件,都自动保存到指定文件夹,不需要什么程序界面美观。。。。
测试通过
Dim Wordobj As Word.Application
Dim xlApp As Excel.Application
Private Sub Command1_Click()
Dim i As Long
On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
On Error GoTo 0
If xlApp Is Nothing Then
' MsgBox "没有打开 Excel", vbInformation
Exit Sub
End If
For i = 1 To xlApp.Workbooks.Count
Debug.Print xlApp.Workbooks(i).Name
xlApp.SaveWorkspace ("d:\" & i & ".xls")
Next
'xlApp.ActiveWorkbook.Close
xlApp.Quit
Set xlApp = Nothing
End Sub
Private Sub Command2_Click()
Set Wordobj = Word.Application
If Wordobj.Documents.Count = 0 Then Exit Sub
For i = 1 To Wordobj.Documents.Count
Debug.Print Wordobj.Documents(i).Name
Wordobj.ActiveDocument.SaveAs "d:\" & i & ".doc"
Next
'WordObj.ActiveDocument.Close
Wordobj.Quit
Set Wordobj = Nothing
'WordObj.Documents.Close
End Sub
Private Sub Timer1_Timer()
Command1_Click
Command2_Click
End Sub
邮件已经发你了~