Macro works at home but not at work
Hi All. This is my first post here.
I'm having trouble with a macro working on my home machine but not on my work machine. My home machine runs MS Office Home and Student 2013 on Windows 10 Pro v 1903. My work machine runs MS Office 365 ProPlus on Windows 10 Pro v 1909.
As far as I can tell the dotm file on both machines is exactly the same. There is nothing in the Normal.dotm on both machines when I look at the Developer/Visual Basic enviroment. The Macro Security options on both machines seem to have the same settings. So now I'm beginning to think it may be an issue with an update. They were both working until a recent MS Office update at work. The macro giving me trouble follows. This macro is meant to center a form field when it is selected. That way, I don't have to use the mouse to keep the selected field in view. I'm trying to design a macro enabled test form for my company. Any advice on how to remedy or diagnose the problem would be a great help. Thanks.
Public Sub SelectionScrollIntoMiddleOfView()
AltS = False
Dim pLeft As Long
Dim pTop As Long, lTop As Long, wTop As Long
Dim pWidth As Long
Dim pHeight As Long, wHeight As Long
Dim Direction As Integer
wHeight = PixelsToPoints(ActiveWindow.Height, True)
ActiveWindow.GetPoint pLeft, wTop, pWidth, pHeight, ActiveWindow
ActiveWindow.GetPoint pLeft, pTop, pWidth, pHeight, Selection.Range
Direction = Sgn((pTop + pHeight / 2) - (wTop + wHeight / 2))
Do While Sgn((pTop + pHeight / 2) - (wTop + wHeight / 2)) = Direction And (lTop <> pTop)
ActiveWindow.SmallScroll Direction
lTop = pTop
ActiveWindow.GetPoint pLeft, pTop, pWidth, pHeight, Selection.Range
Loop
End Sub
Last edited by MikeatMSOffice; 02-07-2020 at 03:05 PM.
|