Sub test_hello()
MsgBox "hello"End Sub这个文件中的模块是被调用的对象。再建立一个Excel文件,创建下面的宏用来调用上面的对象。Sub test_calling()Dim xl_wb As Excel.WorkbookDim xl_wb_name As StringWith Application.FileDialog(msoFileDialogFilePicker) '使用文件对话框选取要调用宏所在的文件.AllowMultiSelect = FalseIf .Show = -1Thenxl_wb_name =.SelectedItems(1)End IfEnd With
调用程序: Sub openfile() Workbooks.Open ("被调用文件.xls") Workbooks("被调用文件.xls").Sheets("Sheet1").test End Sub 被调用文件,Sheet1代码: Public Sub test() Beep End Sub。


- 相关评论
- 我要评论
-