LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Enable copy and paste numbers to and from Calculator

You can use CTRL+C to copy the contents of the Calculator's result
window to the clipboard, and CTRL+V to paste the clipboard into the
result window.

In the interest of science, if you want to do this programmatically,
you can use:

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (
_
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias
"FindWindowExA" ( _
ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA"
( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long


Sub CalcResultToCell()
Dim CalcHWnd As Long
Dim CalcEdit As Long
Dim S As String
Dim L As Long
Dim DataObj As New MSForms.DataObject
Const WM_COPY = &H301
Const CF_TEXT = 1
Const EM_SETSEL = &HB1
CalcHWnd = FindWindow(vbNullString, "Calculator")
If CalcHWnd = 0 Then
MsgBox "Can't find Calculator"
Exit Sub
End If
CalcEdit = FindWindowEx(CalcHWnd, 0&, "Edit", vbNullString)
If CalcEdit = 0 Then
MsgBox "Can't find Edit window"
Exit Sub
End If
L = SendMessage(CalcEdit, EM_SETSEL, 0&, 255&)
L = SendMessage(CalcEdit, WM_COPY, 0&, 0&)
' at this point, the contents of the calculator window are in the
clipboard.
' the next lines take it off the clipboard and put it into
variable S and
' then S into A1.
DataObj.GetFromClipboard
S = DataObj.GetText
Range("A1").Value = S

End Sub


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Sat, 15 Aug 2009 12:21:02 -0700, oldneezer
wrote:

I was trying to use the Calculator and was surprised that I could not copy
numbers from the results of the calculator into Excel. Similarly I could not
copy numbers from my spreadsheet and paste them into the calulator. Of
course, I could have just used Excel in the first place but I did not want to
mess up any of my cells.

Actually this should be a post to the Operating System as the Calculator is
a part of it, but I could not find a place to make a suggestion for the
Operationg System - I am using Vista Home Premium. Maybe Micorosoft can fix
it for Windows 7.

 
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
How to enable Copy/Paste on protected work sheet? dveeraj New Users to Excel 1 August 10th 09 06:49 PM
copy & paste numbers instead of formula AmmHan Excel Discussion (Misc queries) 2 July 21st 09 02:49 PM
How to enable Copy and Paste when the sheet and workbook is protected Yuvraj Excel Discussion (Misc queries) 1 July 20th 09 04:24 PM
How do i copy numbers from Web and paste to excel and and get tota jw austin Excel Worksheet Functions 3 July 26th 06 10:22 PM
how can i enable or disable the paste option in excel 2000 mianmian Excel Worksheet Functions 0 September 2nd 05 09:57 AM


All times are GMT +1. The time now is 02:56 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"