Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB locks up Excel

Status
Not open for further replies.

DGA15

Programmer
Aug 19, 2000
40
US
Using VB 6.0 and Office 2000 to create many large Excel workbooks and worksheets. When using "Range approach" to setting values/formating the WB/WS are created successuly, but cannot be opened w/o closing the VB application. When using a "Cells-Appraoch", it works OK but is VERY VERY slow; 25-40 minutes in the real application. Sample code below:
'.....you create application,wb,ws
with wb
with ws
'below will not release Excel, cannot open WB without_ closing VB application
.Range(Cells(1,1).Cells(20,14)).Value = "12345"
'---------------------------------------
'below will enable Excel opening w/o closing vb_ 'application
' for i = 1 to 20
' for j = 1 to 14
' .Cells(i,j).value = "12345"
' next j
' next i
'----------------------------------------
end with
end with
excelapp.quit
set ws = nothing
set wb=nothing
set excelapp=nothing


 
I am not sure this will solve the problem, but I don't think that you need the 'with wb' line since ws is a property of wb.

Set ws = wb.Sheets("YourSheet")

So ws will already reference wb.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top