Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding a Custom Control at Runtime (Word 97SR2)

    I know how to add a form control to a userform at runtime. I
    want to know how to add a "custom" ActiveX control at
    runtime. Anybody?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding a Custom Control at Runtime (Word 97SR2)

    AFAIK, the custom control has to be registered. That is, you must be able to find the control's ProgID in the Windows Registry under HKEY_CLASSES_ROOT.

    Then you can use code like

    Dim ctl As Control
    Set ctl = Me.Controls.Add("MyProgID", "MyCtl", True)
    With ctl
    .Width = 200
    ' etc.
    End With

    "MyProgID" is the ProgID, "MyCtl" is the name of the control (if omitted, VB assigns a standard name) and True indicates that the control will be visible (can be omitted, True is default).

    For example, to create a calendar control:

    Set c = Me.Controls.Add("MScal.Calendar", "MyCal", True)

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a Custom Control at Runtime (Word 97SR2)

    Hans,
    Thanks. I think your calendar control example puts me on track!
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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