Error on opening more than one workbook containing the same code

J

john.mctigue

Excel 2002 SP-2

I have a series of workbooks that contain identical code. This
includes formatting of a worksheet area which is triggered on opening
the workbook:

Private Sub Workbook_Open()

'---------------------'
'Name the 'Base' range'
'---------------------'
ThisWorkbook.Names.Add Name:="Base", _
RefersTo:="=Sheet1!$A$21", Visible:=True

Call SetupTemplateArea

.....


Sub SetupTemplateArea()

Dim mysheet As Worksheet

Set mysheet = ThisWorkbook.Worksheets("Sheet1")

'Define and format the template work area
mysheet.Range(Range("Base").Offset(0, 0), Range("Base").Offset(5,
8)).Name = "TEMPLATE_AREA"


If I open more than one workbook from the same Open dialog box then the
code fails at the line above for all workbooks, except for the last
which opens normally after the code in each of the other workbooks is
reset. The error is Run-time error '1004': Method 'Range' of object
'_Worksheet' failed.

The workbooks behave normally when opened individually.

Any help would be appreciated.

Kind regards,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top