Auto_open MAcro

J

John McCabe

I have a TOC(table of contents) macro and it works great. Also have the
auto_open macro to start on the first sheet.
Trying to give users the option of creating the TOC sheet and then of course
always start on that sheet. But would have NO auto_open unless they
actually want the TOC sheet to be there. Somehow is there a way to have the
TOC macro create also the auto open macro
 
B

Bob Phillips

Dim StartLine As Long

With ActiveWorkbook.VBProject.VBComponents("Module1").CodeModule
.InsertLines .CountOfLines, _
"Public Sub Auto_Open()" & vbCrLf & _
"Dim ans" & vbCrLf & _
" ans = Msgbox( ""All OK"",vbYesNo)" & vbCrLf & _
" If ans = vbNo Then Cancel = True" & vbCrLf & _
"End Sub"
End With
 

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