LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Creating a procedure using VBA Code

On Feb 5, 3:21*pm, "Bob Phillips" wrote:
Here is an example

Dim StartLine As Long

* * With ActiveWorkbook.VBProject.VBComponents("Sheet1").Co deModule
* * * * StartLine = .CreateEventProc("Click", "CommandButton1") + 1
* * * * .InsertLines StartLine, _
* * * * "Dim ans" & vbCrLf & _
* * * * " * ans = Msgbox( ""All OK"",vbYesNo)" & vbCrLf & _
* * * * " * If ans = vbNo Then Cancel = True"
* * End With

--
---
HTH

Bob

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

wrote in message

...



I am using an Excel/VBA application to read SQL databases - then
create a pivot table using that data and put it on a new workbook.


Now I am trying to programmatically add a command button to a sheet on
that new workbook and put code behind it (meaning adding a SUB
procedureto the workbook as well, that is executed by a Click event
on the new command button).


I have the button added and renamed - now I am trying to figure out
how to add a SubProcedureand then the Click event on that command
button.


Any suggestions??- Hide quoted text -


- Show quoted text -


OK - works like a charm - but opens up the VBE Project window - how do
you close that programatically??
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help creating VBA procedure for Open event Bob Excel Programming 2 August 17th 07 02:20 AM
Creating Second Chart via Sub Procedure Error [email protected] Excel Programming 3 October 29th 05 01:42 PM
Creating Second Chart via Sub Procedure Error [email protected] Excel Programming 0 October 28th 05 08:59 AM
Creating An Event Procedure Les Stout[_2_] Excel Programming 4 October 4th 05 02:03 PM
Creating an event procedure question bhofsetz[_6_] Excel Programming 2 June 8th 05 07:03 PM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"