View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default exact copy/paste

Hi JM,

Alt-F11 to open the VBE

Tools | References | Scroll to 'Microsoft Forms 2.0 Object Libary'
Check this library entry | OK
Menus | Insert | Module
Copy / Paste the following code:

'===================
Sub CopyFormula()
Dim x As New DataObject
x.SetText ActiveCell.Formula
x.PutInClipboard
End Sub

'--------------

Sub PasteFormula()
On Error Resume Next
Dim x As New DataObject
x.GetFromClipboard
ActiveCell.Formula = x.GetText
End Sub

'--------------

Sub Add_Controls()
Dim i As Long
Dim onaction_names As Variant
Dim caption_names As Variant
onaction_names = Array("CopyFormula", "PasteFormula")
caption_names = Array("Copy Fixed Formula", _
"Paste Fixed Formula")

With Application.CommandBars("Cell")
For i = LBound(onaction_names) To _
UBound(onaction_names)
With .Controls.Add(Type:=msoControlButton)
.OnAction = ThisWorkbook.Name _
& "!" & onaction_names(i)
.Caption = caption_names(i)
End With
Next i
End With
End Sub

'--------------

Sub Delete_Controls()
Dim i As Long
Dim caption_names As Variant
caption_names = Array("Copy Fixed Formula", _
"Paste Fixed Formula")
With Application.CommandBars("Cell")
For i = LBound(caption_names) To _
UBound(caption_names)
On Error Resume Next
.Controls(caption_names(i)).Delete
On Error GoTo 0
Next i
End With
End Sub
'===================

Place the cursor anywhere inside the Add_Controls macro, press the F5
function key.

Alt-F11 to return to Excel.

Now right-click any cell. The resultant menu will have two new commands,
namely: 'Copy Fixed Formula' and 'Paste Fixed Formula'

The Delete_Controls macro is added to enable you to delete the two new menu
items, should you choose to do so.


---
Regards,
Norman


"jmwismer" wrote in
message ...

Thank you Norman.

I am of no use for OO programming. Any clue where I can find some help
on how to transfer my cells form an object such as MyDataObj (which
gets the clipboard content) to an array cell(i)?

thx,
jm


--
jmwismer
------------------------------------------------------------------------
jmwismer's Profile:
http://www.excelforum.com/member.php...o&userid=28201
View this thread: http://www.excelforum.com/showthread...hreadid=477424