Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My screens are full of stuffs, still need to add a small spreadsheet, maybe one inch high and less than one inch wide. Is there any solution for this? I don't do complicated calculations, just some simple math, but need this window always on top.

share|improve this question
    
What operating system are you on? How many bits? How much do you know about VBA/Macros. Do you want to install third-party software or do it within excel? You can manually resize the window anytime you'd like, but making it "always on top" or "remain visible" is going to be the tricky part. Definitely possible though. –  Raystafarian Mar 7 '12 at 12:58
    
Windows XP Pro, 32, I know very little about VBA/Macros, but good at understand/implement it. I prefer without 3rd-party, it's only a simple calculation, 3rd-party will come with many fancy features that I don't like. –  Jenny Mar 7 '12 at 13:09

2 Answers 2

up vote 1 down vote accepted

This is a shot in the dark, I run Win 7 64bit, but try this:

Declare Function SetWindowPos Lib "user32" _   (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _   ByVal X As Long, ByVal Y As Long, ByVal cx As Long, _   ByVal cy As Long, ByVal uFlags As Long) As Long

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

Const HWND_TOPMOST = -1 Const HWND_NOTOPMOST = -2

Sub AlwaysOnTop()

  Dim hwnd As Long   Dim res As Long

  hwnd = FindWindow("XLMAIN", vbNullString)   res = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, vbNull)

End Sub

Sub NotAlwaysOnTop()

  Dim hwnd As Long   Dim res As Long

  hwnd = FindWindow("XLMAIN", vbNullString)   res = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, vbNull)

End Sub

Put this in VBA and then run the alwaysontop macro. See if it stays on top. It doesn't work for me, even when I converted it to 64-bit.

share|improve this answer
    
Thanks, I will try this. –  Jenny Mar 7 '12 at 13:36
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, _
                                                   ByVal hWndInsertAfter As Long, _
                                                   ByVal X As Long, _
                                                   ByVal Y As Long, _
                                                   ByVal cx As Long, _
                                                   ByVal cy As Long, _
                                                   ByVal wFlags As Long) As Long

Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, _
                                                 ByVal nCmdShow As Long) As Long


Public Function ResizeAccess()
  Dim lngReturn As Long
  Dim hWnd As Long

  ' get app's window handle
  hWnd = Application.hWndAccessApp

  ' move to upper left vorner of screen 0, 0
  ' resize app window to 800 x 600
  lngReturn = SetWindowPos(hWnd, 0, 0, 0, 800, 600, 0)

  ' normalize window
  lngReturn = ShowWindow(hWnd, 1)
End Function
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.