PDA

View Full Version : Solved: Getting result from Public Function



mdmackillop
09-18-2004, 06:23 AM
If I insert the following in a module ("ScrSize") in Personal.xls, what is the code to return the ScreenWidth value for use in another VBA Project?:help
MD


Private Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Public Function ScreenWidth()
ScreenWidth = GetSystemMetrics(SM_CXSCREEN)
End Function
Public Function ScreenHeight()
ScreenHeight = GetSystemMetrics(SM_CYSCREEN)
End Function

Jacob Hilderbrand
09-18-2004, 06:55 AM
Name the project with the function something useful (let's say "MyProject").
Then in the other workbook in VBE select Tools | References.
Add MyProject as a reference.
Then just call the function as you normally would.