J
Jos Vens
Hi,
I was wondering why Excel sometimes loose my public variables. I use the
variables to have references to my open workbooks and their worksheets.
All my workbooks are open. I suppose that when I open a new workbook en
hides it, I have to rerun my procedure DCL_Sheets? The problem is that most
of the time, everything works fine, but all of a sudden, when I use the
reference eg. shSheet22.[A1]="ABC", I get an error and the reason is because
wbFile1 is not anymore recognized.
Thanks
Jos Vens
eg.
Public wbFile1 as workbook, wbFile2 as workbook
Public shSheet11 as worksheet, shSheet12 as worksheet, shSheet21 as
worksheet, shSheet22 as worksheet
Sub DCL_Sheets
set wbFile1 = workbooks("File1.xls")
set wbFile2 = workbooks("File2.xls")
set shSheet11 = wbFile1.sheets("Sheet01")
set shSheet12 = wbFile1.sheets("Sheet02")
set shSheet21 = wbFile2.sheets("Sheet01")
set shSheet22 = wbFile2.sheets("Sheet02")
End sub
I was wondering why Excel sometimes loose my public variables. I use the
variables to have references to my open workbooks and their worksheets.
All my workbooks are open. I suppose that when I open a new workbook en
hides it, I have to rerun my procedure DCL_Sheets? The problem is that most
of the time, everything works fine, but all of a sudden, when I use the
reference eg. shSheet22.[A1]="ABC", I get an error and the reason is because
wbFile1 is not anymore recognized.
Thanks
Jos Vens
eg.
Public wbFile1 as workbook, wbFile2 as workbook
Public shSheet11 as worksheet, shSheet12 as worksheet, shSheet21 as
worksheet, shSheet22 as worksheet
Sub DCL_Sheets
set wbFile1 = workbooks("File1.xls")
set wbFile2 = workbooks("File2.xls")
set shSheet11 = wbFile1.sheets("Sheet01")
set shSheet12 = wbFile1.sheets("Sheet02")
set shSheet21 = wbFile2.sheets("Sheet01")
set shSheet22 = wbFile2.sheets("Sheet02")
End sub