这样只有开启一个Excel文件,求解决 开起多个Excel文件方法
PUBLIC ExcelApp,NowWrite(20),ExcelApp1
Sub StartExcel()
OpenExcelFile
OpenExcelFile2
End sub
Sub OpenExcelFile()
On Error Resume Next
Set ExcelApp = GetObject(,"Excel.Application")
if Err.number<>0 then
Set ExcelApp = CreateObject("Excel.Application")
'打开指定文件
Set ExcelApp = GetObject("d:\金字塔决策交易系统\orderlog\TradeLog.xls")
'打开指定文件
Set ExcelApp = ExcelApp.Workbooks("TradeLog.xls")
If Err.number<>0 then
Set ExcelApp = GetObject("d:\金字塔决策交易系统\orderlog\TradeLog.xls")
End If
end if
ExcelApp.Parent.Windows("TradeLog.xls").Activate
ExcelApp.Application.DisplayFormulaBar=False
If ExcelApp.Application.Visible = False then
ExcelApp.Application.Visible = True
End if
ExcelApp.Application.DisplayAlerts=False
end sub
Sub OpenExcelFile2()
On Error Resume Next
Set ExcelApp1 = GetObject(,"Excel.Application")
if Err.number<>0 then
Set ExcelApp1 = CreateObject("Excel.Application")
'打开指定文件
Set ExcelApp1 = GetObject("d:\金字塔决策交易系统\orderlog\VirtualTradeLog.xls")
'打开指定文件
Set ExcelApp1 = ExcelApp1.Workbooks("VirtualTradeLog.xls")
If Err.number<>0 then
Set ExcelApp1 = GetObject("d:\金字塔决策交易系统\orderlog\VirtualTradeLog.xls")
End If
end if
ExcelApp1.Parent.Windows("VirtualTradeLog.xls").Activate
ExcelApp1.Application.DisplayFormulaBar=False
If ExcelApp1.Application.Visible = False then
ExcelApp1.Application.Visible = True
End if
ExcelApp1.Application.DisplayAlerts=False
end sub