LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Adding commandbutton to sheet

I am a module in an xla to add a command button to a sheet and set the
click event. When I get to the wsLogSheet.CodeName line, it tells me
index out of range. The help says that should be a long and not a
string so I tried using wsLogSheet.Index. The line runs without an
error but my click code is getting added to a module in the xla that is
adding the worksheet instead of getting added to the worksheet. And
then the button doesn't do anything. How do I get the code into the
active worksheet?


Set wsLogSheet = ActiveWorkbook.Worksheets.Add
Set oleo = .OLEObjects.Add(ClassType:="Forms.CommandButton.1" , _
Link:=False, DisplayAsIcon:=False, Left:=378,
Top:=2, _
width:=70, Height:=20)
oleo.Name = "LogSheetAction"
With
ThisWorkbook.VBProject.VBComponents(wsLogSheet.Cod eName).CodeModule
Dim newline As Long
Dim newproc As String

newline = .CountOfLines + 1
newproc = "Sub LogSheetAction_Click()" & vbCrLf &
vbCrLf
newproc = newproc & vbTab & "ShowUpdaterForm" & vbCrLf
& vbCrLf
newproc = newproc & "End Sub"
.InsertLines newline, newproc
End With

 
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
Taking infomation in one sheet and adding it to another sheet BigBadBess24 Excel Discussion (Misc queries) 1 September 19th 06 08:37 PM
VBA to stop XL from adding the Path Sring to Sheet-to-Sheet Links [email protected] Excel Discussion (Misc queries) 5 August 18th 06 01:46 PM
adding data from one sheet to another sheet as a dropdown list bo. gatorguy Excel Discussion (Misc queries) 1 February 18th 05 10:51 PM
ActiveX CommandButton gets renamed when Sheet is cloned running Excel97 JimP Excel Programming 1 December 28th 04 02:32 PM
Adding commandbutton at run time Ron Dahl[_2_] Excel Programming 0 January 20th 04 10:06 PM


All times are GMT +1. The time now is 08:01 AM.

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"