Consulting

Results 1 to 2 of 2

Thread: Solved: Getting result from Public Function

  1. #1
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location

    Solved: Getting result from Public Function

    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?
    MD

    [VBA]
    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

    [/VBA]

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •