How do I add a simple calculator ( Like the one found in accessori

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I add a simple calculator ( Like the one found in accessories) to my
excel spreadsheet. I am doing my personal budgets and often would like to
check how much several items will cost me but without have to go through
accessories to the calculator which disappears when I switch screens.

Is there a way to embedd one in a spread sheet?
 
Steve,

If you can go for a bit of VBA, use code like the following. It will open
the Windows calculator and make it a child of Excel so it will float above
the worksheets as you work in Excel and will be ready to use.

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Public Declare Function SetParent Lib "user32" ( _
ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long

Sub ShowCalc()
Dim XLHwnd As Long
Dim CalcHWnd
XLHwnd = Application.Hwnd
Shell "calc.exe"
CalcHWnd = FindWindow("SciCalc", "Calculator")
If CalcHWnd > 0 Then
SetParent CalcHWnd, XLHwnd
End If

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
Steve

Excel is a giant calculator.....use it to calculate your item costs.

Just as fast to enter 100 in A1 and 234 in A2 and 651 in A3 then use the
Autosum button as it is to enter the numbers in a calcultor.

Have you thought about creating a shortcut to the Acessories Calculator and
sticking it on your QuickLaunch Toolbar?

OR you could add a macro to call up the Calculator and assign it to a button on
a toolbar.

Sub calc()
Dim taskID As Variant
On Error Resume Next
Shell ("C:\windows\system32\calc.exe"), vbNormalFocus
If Err <> 0 Then _
MsgBox "Calculator is Missing"
End Sub


Gord Dibben MS Excel MVP
 
Hello. May I ask a question about your code below, just for my general
edification?

Why was the taskID variable created but not used? I can't understand its
point.
 
Just cobbled together fromk something else and left it in.

Not needed, nor the path.

Sub calc()
On Error Resume Next
Shell ("calc.exe"), vbNormalFocus
If Err <> 0 Then _
MsgBox "Calculator is Missing"
End Sub


Gord
 
Steve said:
How do I add a simple calculator ( Like the one found in accessories) to my
excel spreadsheet. I am doing my personal budgets and often would like to
check how much several items will cost me but without have to go through
accessories to the calculator which disappears when I switch screens.

Is there a way to embedd one in a spread sheet?
 
Hi Chip,

I like your code, is there a way to force the calculator to show up on
specific position of the screen, if so, can you provide the code.

Thanks
Andy
 
Back
Top