Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 300
Default Can I put buttons on a sheet without selecting?

I'd prefer if this macro added the buttons without selecting the sheet. And
even work if another workbook is active.

Sub AddButtonsToPage()

Application.ScreenUpdating = False
ThisWorkbook.Activate
Sheets("BondCalc").Select

If ActiveSheet.Shapes.Count = 0 Then
ActiveSheet.Buttons.Add(400, 20, 170, 23).Select
Selection.OnAction = "CopyBondCalcSheet"
Selection.Characters.Text = "Put Page Contents into Clipboard"

ActiveSheet.Buttons.Add(400, 55, 72, 23).Select
Selection.OnAction = "ClearBondCalcSheet"
Selection.Characters.Text = "Clear Page"
End If

Range("A1").Select

End Sub

Is it possible?

Don. www.donwiss.com (e-mail link at home page bottom).
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 300
Default Can I put buttons on a sheet without selecting?

I played around with it and this works. And *much* more elegant.

Sub AddButtonsToPage()

Application.ScreenUpdating = False
With ThisWorkbook.Sheets("BondCalc")

If .Shapes.Count = 0 Then
With .Buttons.Add(400, 20, 170, 23)
.OnAction = "CopyBondCalcSheet"
.Characters.Text = "Put Page Contents into Clipboard"
End With

With .Buttons.Add(400, 55, 72, 23)
.OnAction = "ClearBondCalcSheet"
.Characters.Text = "Clear Page"
End With
End If

End With

End Sub

Don. www.donwiss.com (e-mail link at home page bottom).
Reply
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
Selecting 3 buttons out of a 3 x 3 array of options. Tayo Excel Discussion (Misc queries) 1 February 20th 09 01:53 AM
Selecting Radio Buttons by Using Macros ac1179 Excel Programming 2 October 17th 08 10:57 PM
Selecting Form buttons art Excel Programming 1 October 6th 08 01:29 PM
selecting using option buttons in excel stedroyf Excel Worksheet Functions 0 November 3rd 06 10:01 PM
selecting sheet name in another workbook by variable (same sheet name) Craig[_24_] Excel Programming 1 April 25th 06 05:45 PM


All times are GMT +1. The time now is 03:57 PM.

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

About Us

"It's about Microsoft Excel"