Thread: Timing Issue??
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Geoff Geoff is offline
external usenet poster
 
Posts: 371
Default Timing Issue??

Hi Vasant
Thanks for the reply , but nope.
Qualifying the sheet does not cure the problem. At least if i understand
what you mean with :
Set ws = ThisWorkbook.Sheets(Sheets.Count).

I might add here that I am not trying to run the installed proc at this
stage merely to insert it into the worksheet module.

Again fails on every new workbook instance but then works after breaking and
continue.

Geoff



"Vasant Nanavati" wrote:

ThisWorkbook refers to the workbook containing the code. You need to specify
the specific workbook that you want to operate on.

--

Vasant


"Geoff" wrote in message
...
Hi
I am trying to adapt Chip Pearson's code and insert the same procedure
into
2 added worksheets.

Strange thing is my code only fails each time I start a new instance of
the
workbook. Even then, when the code breaks on error with 'Subscript out of
Range' and I click to continue in Debug mode the code completes without
error
AND the new module is installed correctly in both new worksheets.

Within the same instance of the workbook and beyond the initial 'block'
the
procedure works without hesitation repeatedly. When creating the second
of
the 2 worksheets, the code never fails whether it is in the first instance
of
the workbook or not.

The fact that the identical code works on the second worksheet insert and
works repeatedly thereafter (within the same wb instance) suggests a
compile
timing problem but how do I get around it?
The code fails at *** with Subscript out of Range...

Sheets.Add After:=Sheets(Sheets.Count)
Set ws = Sheets(Sheets.Count)
With ThisWorkbook.VBProject.VBComponents(ws.CodeName).C odeModule '***
.InsertLines .CountOfLines + 1, _
'required proc'
End With

What am I missing? I would appreciate any help.

T.I.A.

Geoff