adding code lines with vba code

  • Thread starter Thread starter thread
  • Start date Start date
T

thread

Hi all
does anyone have examples of vba code that adding vba code line?
 
I think you may have to provide us with a more detailed description of what
you are trying to do.

Rick
 
Dim StartLine As Long

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


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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

Back
Top