cgmojoco
Well-known Member
- Joined
- Jan 15, 2005
- Messages
- 699
I'm using this code to update a userform (this is code that is part of a progress bar):
Is there a way to do the same thing without having to focus on the activewindow (if I go to surf the net while this script is called in one of my subroutines I get an error---I'm assuming excel can't find the activewindow?)
Code:
Private Sub UserForm_Activate()
Dim lTop As Long, lLeft As Long
Dim lRow As Long, lCol As Long
With ActiveWindow.VisibleRange
lRow = .Rows.Count / 2
lCol = .Columns.Count / 2
End With
With Cells(lRow, lCol)
lTop = .Top
lLeft = .Left
End With
With Me
.Top = lTop
.Left = lLeft
End With
End Sub
Is there a way to do the same thing without having to focus on the activewindow (if I go to surf the net while this script is called in one of my subroutines I get an error---I'm assuming excel can't find the activewindow?)