Consulting

Results 1 to 3 of 3

Thread: Solved: Convertiing a Macro to Script

  1. #1

    Solved: Convertiing a Macro to Script

    I have a problem seeing input areas (login password, forum posts, etc.) on certain web sites because I use a black background on my screen. I wrote a macro that will toggle between my normal screen colors and a set that permits me to see the ?invisible? areas of those web sites.

    It has proved VERY handy, but in order to use it I have to click a button that brings up an Excel workbook, which contains and initiates execution of the macro. It actually goes pretty fast, but it?s a clumsy way to do what I want to do. My question is:

    Is there a way to convert the macro into Script so I can ?run? it? I have no background in Script, and I would rather not go through the learning curve of educating myself on a new language just to make this conversion.

    The basic statements I use are:
    [VBA] 'Declare required API functions
    Private Declare Function SetSysColors Lib "user32" (ByVal nChanges&, lpSysColor&, lpColorValues&) As Long
    Private Declare Function GetSysColor Lib "user32" (ByVal nIndex&) As Long

    Sub ToggleScreenColors()
    Dim WinSysColors&, WindowColor, WindowTxtColor
    Worksheets("Main").Select
    WinSysColors = GetSysColor(COLOR_WINDOW)
    If WinSysColors = 0 _
    Then
    WindowColor = SetSysColors(1, COLOR_WINDOW, RGB(0, 255, 255)) 'Cyan
    WindowTxtColor = SetSysColors(1, COLOR_WINDOWTEXT, RGB(0, 0, 0)) 'Black
    Else
    WindowColor = SetSysColors(1, COLOR_WINDOW, RGB(0, 0, 0)) 'Black
    WindowTxtColor = SetSysColors(1, COLOR_WINDOWTEXT, RGB(0, 255, 255)) 'Cyan
    End If
    Range("C6").Select
    End Sub 'ToggleScreenColors'[/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    The problem is that you cannot natively call a Win32 API in scripts, you need a custom control to do it. I have not found any free instances of these.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thanx for the reply, xld. I was afraid you might say something like that. Oh well ... just wishing.

Posting Permissions

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