我无法弄清楚为什么将Excel传递给另一个函数或带有VB6的子程序时,某些用户(但不是全部)看到错误的原因。
对于部分但并非全部失败。他们会丢失DLL或接口未注册错误。
sub test()
Dim xl As Object, xlwbook As Object, xlsheet As Object
Set xl = CreateObject("excel.application")
Set xlwbook = xl.Workbooks.Add(xlWBATWorksheet)
xlwbook.Sheets("Sheet1").Name = "REPORT"
Set xlsheet = xlwbook.Sheets("REPORT")
Call formatlogo(xlsheet)
End Sub
function formatlogo(xlsheet As Worksheet)
xlsheet.Cells(1, 1).Characters(1, 1).Font.Name = "Webdings"
end function
这适用于所有人。
sub test()
Dim xl As Object, xlwbook As Object, xlsheet As Object
Set xl = CreateObject("excel.application")
Set xlwbook = xl.Workbooks.Add(xlWBATWorksheet)
xlwbook.Sheets("Sheet1").Name = "REPORT"
Set xlsheet = xlwbook.Sheets("REPORT")
xlsheet.Cells(1, 1).Characters(1, 1).Font.Name = "Webdings"
End Sub
为什么某些人不能传递没有dll错误的Excel对象? 先感谢您。