About dialog sample

Discussion in 'AutoCAD' started by David Allen, Sep 1, 2004.

  1. David Allen

    David Allen Guest

    I need a vba sample code to make an about dialog box for use in my companies pulldown menu.
    I would like to have the company logo and a hyperlink. Thats why I am thinking that VBA will be
    the only easy way to do this. I don't know much about programing VBA yet so I was looking for
    samples.

    David
     
    David Allen, Sep 1, 2004
    #1
  2. For starters you're going to have to look for a 3rd party control because
    vba doesn't provide a hyperlink control. You can browse your system and
    find the microsoft one but you can't legally use it per their EULA. Check
    out a site like vbAccelerator which has decent free controls. They would
    also have an example app for you so you can see how to use their control.
    Then come back here for help in running it from a menu pulldown.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 1, 2004
    #2
  3. A label can be used with a code snippet like this:

    Private Sub Label1_Click()
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run "http://www.jtbworld.com"
    End Sub

    If you want you can set the label text to underlined and blue as a
    hyperlink.

    --
    Best Regards, Jimmy Bergmark
    CAD and Database Developer Manager at www.pharmadule-emtunga.com
    Take a look at
    JTB FlexReport (FLEXlm report tool) - www.jtbworld.com/jtbflexreport
    SmartPurger (Purges automatically) - www.jtbworld.com/?/smartpurger.htm
    or download some freeware at www.jtbworld.com
    More on AutoCAD 2005;
    www.jtbworld.com/autocad2005.htm
     
    Jimmy Bergmark, Sep 1, 2004
    #3
  4. David Allen

    MP Guest

    very clever dude!!!!
    :)
     
    MP, Sep 1, 2004
    #4
  5. David Allen

    Matt W Guest

    Add this to the mix and the label will turn blue (to indicate a hyperlink)
    and then back to it's normal color when the mouse is moved over any part of
    the form...


    Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As
    Integer, ByVal X As Single, ByVal Y As Single)
    Label1.ForeColor = vbBlue
    End Sub

    Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
    Integer, ByVal X As Single, ByVal Y As Single)
    Label1.ForeColor = &H80000012
    End Sub


    --
    Matt W

    The difference between genius and stupidity is that genius has its limits.
    | very clever dude!!!!
    | :)
    |
    | | > A label can be used with a code snippet like this:
    | >
    | > Private Sub Label1_Click()
    | > Set WshShell = CreateObject("WScript.Shell")
    | > WshShell.Run "http://www.jtbworld.com"
    | > End Sub
    | >
    | > If you want you can set the label text to underlined and blue as a
    | > hyperlink.
    | >
    |
    |
     
    Matt W, Sep 1, 2004
    #5
  6. Neat trick, guys. Never thought of that approach =)

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 1, 2004
    #6
  7. David Allen

    Ed Jobe Guest

    I just use a button on my About form with this function I wrote. If you want
    the whole thing, its part of my TextUtilities on the AUGI Exchange. But that
    version is just missing the button that goes to our intranet. Just add a
    button with the function below.

    Public Sub Browse(Optional URL As String, Optional winstyle As
    VbAppWinStyle)
    'opens IE in last WinStyle if WinStyle is not supplied

    'Nav to home page if url is blank
    If Not URL = "" Then URL = " " & URL
    'make sure your path to IE is correct
    Shell "C:\Program Files\Internet Explorer\IEXPLORE.EXE" & URL, winstyle
    End Sub
     
    Ed Jobe, Sep 1, 2004
    #7
  8. James Belshan, Sep 1, 2004
    #8
  9. David Allen

    David Allen Guest

    ok I got this code
    I got the hyperlink for the web site to work properly, but when I move the mouse over the email it stays blue
    Also should the OK button work when I preview it via the VBAIDE?




    Private Sub CommandButton1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

    End Sub

    Private Sub Label3_Click()
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run "http://www.domain.com"
    End Sub

    Private Sub Label3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Label3.ForeColor = vbBlue
    End Sub

    Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Label3.ForeColor = &H80000012
    End Sub

    Private Sub Label4_Click()
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run "mailto:"
    End Sub

    Private Sub Label4_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Label4.ForeColor = vbBlue
    End Sub

    Private Sub UserForm2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Label4.ForeColor = &H80000012
    End Sub



    "Matt W" <>
    |>Add this to the mix and the label will turn blue (to indicate a hyperlink)
    |>and then back to it's normal color when the mouse is moved over any part of
    |>the form...
    |>
    |>
    |>Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As
    |>Integer, ByVal X As Single, ByVal Y As Single)
    |> Label1.ForeColor = vbBlue
    |>End Sub
    |>
    |>Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
    |>Integer, ByVal X As Single, ByVal Y As Single)
    |> Label1.ForeColor = &H80000012
    |>End Sub


    David
     
    David Allen, Sep 2, 2004
    #9
  10. David Allen

    David Allen Guest

    LOL

    that's hot. I like that, thankx

    "Matt W" <>
    |>I'd opt for the easy way out...
    |>Change the mousepointer for the label from 0 (the default) to 99 (custom).
    |>Then for the MouseIcon, use the attached CURsor for the "full effect".


    David
     
    David Allen, Sep 2, 2004
    #10
  11. David Allen

    David Allen Guest

    Also how do I run this from a command line?

    David Allen <*@*.com>
    |>ok I got this code
    |>I got the hyperlink for the web site to work properly, but when I move the mouse over the email it stays blue
    |>Also should the OK button work when I preview it via the VBAIDE?
    |>
    |>
    |>
    |>
    |>Private Sub CommandButton1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    |>
    |>End Sub
    |>
    |>Private Sub Label3_Click()
    |> Set WshShell = CreateObject("WScript.Shell")
    |> WshShell.Run "http://www.domain.com"
    |>End Sub
    |>
    |>Private Sub Label3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    |> Label3.ForeColor = vbBlue
    |>End Sub
    |>
    |>Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    |> Label3.ForeColor = &H80000012
    |>End Sub
    |>
    |>Private Sub Label4_Click()
    |> Set WshShell = CreateObject("WScript.Shell")
    |> WshShell.Run "mailto:"
    |>End Sub
    |>
    |>Private Sub Label4_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    |> Label4.ForeColor = vbBlue
    |>End Sub
    |>
    |>Private Sub UserForm2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    |> Label4.ForeColor = &H80000012
    |>End Sub
    |>
    |>
    |>
    |>"Matt W" <>
    |>|>Add this to the mix and the label will turn blue (to indicate a hyperlink)
    |>|>and then back to it's normal color when the mouse is moved over any part of
    |>|>the form...
    |>|>
    |>|>
    |>|>Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As
    |>|>Integer, ByVal X As Single, ByVal Y As Single)
    |>|> Label1.ForeColor = vbBlue
    |>|>End Sub
    |>|>
    |>|>Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
    |>|>Integer, ByVal X As Single, ByVal Y As Single)
    |>|> Label1.ForeColor = &H80000012
    |>|>End Sub
    |>
    |>
    |>David


    David
     
    David Allen, Sep 2, 2004
    #11
  12. David Allen

    Matt W Guest

    Can you post your program (zip it up)


    --
    Matt W

    The difference between genius and stupidity is that genius has its limits.
    | ok I got this code
    | I got the hyperlink for the web site to work properly, but when I move the
    mouse over the email it stays blue
    | Also should the OK button work when I preview it via the VBAIDE?
    |
    |
    |
    |
    | Private Sub CommandButton1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    |
    | End Sub
    |
    | Private Sub Label3_Click()
    | Set WshShell = CreateObject("WScript.Shell")
    | WshShell.Run "http://www.domain.com"
    | End Sub
    |
    | Private Sub Label3_MouseMove(ByVal Button As Integer, ByVal Shift As
    Integer, ByVal X As Single, ByVal Y As Single)
    | Label3.ForeColor = vbBlue
    | End Sub
    |
    | Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
    Integer, ByVal X As Single, ByVal Y As Single)
    | Label3.ForeColor = &H80000012
    | End Sub
    |
    | Private Sub Label4_Click()
    | Set WshShell = CreateObject("WScript.Shell")
    | WshShell.Run "mailto:"
    | End Sub
    |
    | Private Sub Label4_MouseMove(ByVal Button As Integer, ByVal Shift As
    Integer, ByVal X As Single, ByVal Y As Single)
    | Label4.ForeColor = vbBlue
    | End Sub
    |
    | Private Sub UserForm2_MouseMove(ByVal Button As Integer, ByVal Shift As
    Integer, ByVal X As Single, ByVal Y As Single)
    | Label4.ForeColor = &H80000012
    | End Sub
    |
    |
    |
    | "Matt W" <>
    | |>Add this to the mix and the label will turn blue (to indicate a
    hyperlink)
    | |>and then back to it's normal color when the mouse is moved over any part
    of
    | |>the form...
    | |>
    | |>
    | |>Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As
    | |>Integer, ByVal X As Single, ByVal Y As Single)
    | |> Label1.ForeColor = vbBlue
    | |>End Sub
    | |>
    | |>Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
    | |>Integer, ByVal X As Single, ByVal Y As Single)
    | |> Label1.ForeColor = &H80000012
    | |>End Sub
    |
    |
    | David
     
    Matt W, Sep 2, 2004
    #12
  13. David Allen

    David Allen Guest

    posted to customer files

    "Matt W" <>
    |>Can you post your program (zip it up)


    David
     
    David Allen, Sep 2, 2004
    #13
  14. David Allen

    Matt W Guest

    Add this to the Userform MouseMove event: Label4.ForeColor = &H80000012

    The OK button doesn't have any code behind it.

    And to run it from the command line, first add this your module:

    Public Sub Main()
    WW_About.Show
    End Sub

    Then you can use this code to run it from the command line: ^C^C_-vbarun
    About.dvb!Module1.Main;
    --
    Matt W

    The difference between genius and stupidity is that genius has its limits.


    | ok I got this code
    | I got the hyperlink for the web site to work properly, but when I move the
    mouse over the email it stays blue
    | Also should the OK button work when I preview it via the VBAIDE?
    |
    |
    |
    |
    | Private Sub CommandButton1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    |
    | End Sub
    |
    | Private Sub Label3_Click()
    | Set WshShell = CreateObject("WScript.Shell")
    | WshShell.Run "http://www.domain.com"
    | End Sub
    |
    | Private Sub Label3_MouseMove(ByVal Button As Integer, ByVal Shift As
    Integer, ByVal X As Single, ByVal Y As Single)
    | Label3.ForeColor = vbBlue
    | End Sub
    |
    | Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
    Integer, ByVal X As Single, ByVal Y As Single)
    | Label3.ForeColor = &H80000012
    | End Sub
    |
    | Private Sub Label4_Click()
    | Set WshShell = CreateObject("WScript.Shell")
    | WshShell.Run "mailto:"
    | End Sub
    |
    | Private Sub Label4_MouseMove(ByVal Button As Integer, ByVal Shift As
    Integer, ByVal X As Single, ByVal Y As Single)
    | Label4.ForeColor = vbBlue
    | End Sub
    |
    | Private Sub UserForm2_MouseMove(ByVal Button As Integer, ByVal Shift As
    Integer, ByVal X As Single, ByVal Y As Single)
    | Label4.ForeColor = &H80000012
    | End Sub
    |
    |
    |
    | "Matt W" <>
    | |>Add this to the mix and the label will turn blue (to indicate a
    hyperlink)
    | |>and then back to it's normal color when the mouse is moved over any part
    of
    | |>the form...
    | |>
    | |>
    | |>Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As
    | |>Integer, ByVal X As Single, ByVal Y As Single)
    | |> Label1.ForeColor = vbBlue
    | |>End Sub
    | |>
    | |>Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As
    | |>Integer, ByVal X As Single, ByVal Y As Single)
    | |> Label1.ForeColor = &H80000012
    | |>End Sub
    |
    |
    | David
     
    Matt W, Sep 2, 2004
    #14
  15. David Allen

    David Allen Guest

    See below

    "Matt W" <>
    |>Add this to the Userform MouseMove event: Label4.ForeColor = &H80000012

    Where is this revision? Where is the userform mousemove event?


    |>The OK button doesn't have any code behind it.

    What does a close dialog box code look like?


    |>And to run it from the command line, first add this your module:
    |>
    |>Public Sub Main()
    |> WW_About.Show
    |>End Sub

    Whats the syntax here? Where do I add this code? At the bottom of my other code?
    Whats the command WW_About?


    |>Then you can use this code to run it from the command line: ^C^C_-vbarun
    |>About.dvb!Module1.Main;

    Where does the Module1.Main come from?

    Sorry for my ingorance but all I know is lisp structure, not vba :)


    David
     
    David Allen, Sep 2, 2004
    #15
  16. David Allen

    MP Guest

    I see Matt already got back to you, but here's a couple answers to your
    questions as well.

    at the top of the code pane in the vbaide there are two dropdown listboxes
    the one on the left lists the objects in your project
    activate the form in your project box (f7 to view code)
    select userform from the left hand dropdown list
    then the righthand will list the events available for the form
    select mousemove
    that will put the blank sub in your code
    paste matts code inside the sub framework

    anywhere in a standard module in your project
    that's not a command.
    "ww_about" is the name of your form apparently
    show is a method of a form that makes the form appear on your screen

    Objectname.Methodname calls the method(sub or function) "MethodName"
    defined on the object "ObjectName"
    if your form is named "Ww_about", then type ww_about. (notice the ending dot
    .. ) and a dropdown list will appear with all the methods and properties
    available for that form (or any other named object you type)
    (that's called "intellisense")

    he just wrote it for you above
    you put the sub Main above into a standard module (the default name if you
    insert a module into your project is Module1)

    Modulename.Subname - runs "subname" defined in "modulename"
    it helps to spend a little time in the help files for vba to get some of the
    overview on how the language is structured

    hth
    Mark
     
    MP, Sep 2, 2004
    #16
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.