D
Dave
Excel 2000 SP-3, Win2000
Hi- I've been puzzling on this one for a while and can't
find an answer in the archives- can anyone help?
When Excel starts it opens a default blank workbook. If I
then open a previously saved workbook then the default
workbook is automatically closed before the selected
workbook is openned.
My problem is that this behaviour occurs when openning
files from an add-in, for example:
1) User opens Excel and is presented with the default
workbook.
2) User imediately runs my add-in from a custom menu item
3) My add-in does something like this:
Sub MY_ADDIN
Dim rngR as Range
Dim wsData as Worksheet
Dim strData as String
Set rngR = Selection
Set wsData = Workbooks.Open("C:\Test.xls").Sheets(1)
strData = wsData.Range("A1").Formula
wsData.Parent.Parent.Close(False)
rngR.Formula = strData
End Sub
When the file Test.xls is openned, this has the undesired
effect of closing the default workbook. The range rngR is
lost and I get an Error 424 (Object required) error on the
last line.
How can I prevent the default workbook from being closed
in this situation?
Cheers,
Dave
Hi- I've been puzzling on this one for a while and can't
find an answer in the archives- can anyone help?
When Excel starts it opens a default blank workbook. If I
then open a previously saved workbook then the default
workbook is automatically closed before the selected
workbook is openned.
My problem is that this behaviour occurs when openning
files from an add-in, for example:
1) User opens Excel and is presented with the default
workbook.
2) User imediately runs my add-in from a custom menu item
3) My add-in does something like this:
Sub MY_ADDIN
Dim rngR as Range
Dim wsData as Worksheet
Dim strData as String
Set rngR = Selection
Set wsData = Workbooks.Open("C:\Test.xls").Sheets(1)
strData = wsData.Range("A1").Formula
wsData.Parent.Parent.Close(False)
rngR.Formula = strData
End Sub
When the file Test.xls is openned, this has the undesired
effect of closing the default workbook. The range rngR is
lost and I get an Error 424 (Object required) error on the
last line.
How can I prevent the default workbook from being closed
in this situation?
Cheers,
Dave