How to create button "Paste special, All except border"


Posted by mabaud on December 01, 2000 12:32 AM

I would like to create a button (in my toolbar) that would do a "paste special, all except border". How do I do?
Thanks for your help
mabaud



Posted by Ivan Moala on December 01, 2000 3:18 AM

To create a button on your main toolbar then
In your Thisworkbook excel object place this code.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Delete_Button
End Sub

Private Sub Workbook_Open()
Create_Button
End Sub


In a module place this code

Sub Paste_Spec()
On Error Resume Next
Selection.PasteSpecial Paste:=7
If Err.Number = 1004 Then MsgBox "No data to PasteSpecial": End
Application.CutCopyMode = False
End Sub

Sub Create_Button()
Dim Menu As CommandBarButton
Set Menu = Application.CommandBars(1).Controls.Add(Type:=msoControlButton, _
Before:=10)
With Menu
.Style = msoButtonCaption
.Caption = "MyPaste"
.OnAction = "Paste_Spec"
End With
End Sub

Sub Delete_Button()
Application.CommandBars(1).Controls("MyPaste").Delete
End Sub

HTH

Ivan