Difference between CreateObject(“Excel.Application”) .Workbooks.Open and just Workbooks.Open

前端 未结 2 1572
北恋
北恋 2021-02-12 22:49

I am currently using Workbooks.Open to process a large number of files contained in a directory. But opening and closing these files make the files appear in the ta

2条回答
  •  广开言路
    2021-02-12 23:39

    Late binding is slightly slower than early binding, but you may not even notice the difference. Yes, you can use just use one instance for all the workbooks. Note that this:

    Dim xl As New Excel.Application
    
    xl.Workbooks.Open "z:\docs\test.xlsm"
    

    Will not be visible unless you say:

    xl.Visible = True
    

    Be sure to close any instances in your error trap.

提交回复
热议问题