Return to excel from vbe

B

bobbo

I wrote a procedure that inserts two procedures into the activeworkbook
ThisWorbook module. I am trying to make a utility for novice users and
would like them not to see the vbe (it scares them). After the code is
written the vbe stays open on the ThisWorkbook module. What is the code
equivalent of alt + F11?
 
B

bobbo

Thanks that works. Is there a way to keep the screen from hopping back
and forth from excel to vbe while the code is executing or will I just
have to live with that?
 
R

Ron de Bruin

When you create the code you not have to display the VBE
you can run code like this without opening the VBE

See also Chip's site
http://www.cpearson.com/excel/vbe.htm

Sub AddProcedure()
Dim VBCodeMod As CodeModule
Dim LineNum As Long

Set VBCodeMod = ThisWorkbook.VBProject.VBComponents("Sheet1").CodeModule
With VBCodeMod
LineNum = .CountOfLines + 1
.InsertLines LineNum, _
"Sub MyNewProcedure()" & Chr(13) & _
" Msgbox ""Here is the new procedure"" " & Chr(13) & _
"End Sub"
End With
End Sub
 

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