Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    What does this code do? (Excel XP)

    This code is in a module which demonstrates how to start an application (Character Map) from a macro button. It is simple enough to determine what the second <font color=blue>Sub RunCharMap()</font color=blue> does. But the first <font color=blue>Declare Function ...</font color=blue> is in the same module and I have no idea of it's purpose.

    <pre>Declare Function OpenProcess Lib "kernel32" _
    (ByVal dwDesiredAccess As Long, _
    ByVal bInheritHandle As Long, _
    ByVal dwProcessId As Long) As Long

    Declare Function GetExitCodeProcess Lib "kernel32" _
    (ByVal hProcess As Long, _
    lpExitCode As Long) As Long
    </pre>

    <pre>
    Sub RunCharMap()
    On Error Resume Next
    Program = "Charmap.exe"
    TaskID = Shell(Program, 1)
    If Err <> 0 Then
    MsgBox "Cannot start " & Program, vbCritical, "Error"
    End If
    End Sub
    </pre>

    - Ricky

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What does this code do? (Excel XP)

    Those two statements declare two functions in the Windows API (Application Programming Interface). Neither of these functions are used in the RunCharMap subroutine that you posted.
    Legare Coleman

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Dallas, Texas, USA
    Posts
    1,680
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: What does this code do? (Excel XP)

    Thanks Legare, I have a CD that came with a VBA book. The CD contains examples of the book contents. In the authors example of how to Run CharMap from a macro button, he had included everything that I put in my original post. I assumed the first several lines were not necessary, but wanted to make sure before I messed things up....

    I was interested in adding a <font color=blue>Run</font color=blue> menu item to my standard Excel Menu in the third position after File & Edit. Inside the Run menu, I would include mechanisms for starting several apps, like Character Map, A Tape Calculator...

    Any advice that might keep me from having to reinstall Excel tomorrow? ... <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    - Ricky

  4. #4
    2 Star Lounger
    Join Date
    Dec 2000
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What does this code do? (Excel XP)


Posting Permissions

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