Setting a Font in ActiveX Declaration

MrChuck

New Member
Joined
Aug 6, 2008
Messages
6
Does anyone know what the code should look like to set the initial font (font, style, and size) for an activeX controll. I know to set other properties it is as easy as:

Selection.Object.MultiLine = True
Selection.Object.ScrollBars = 2

The font however seems a bit trixier. Thanks in advance for the help

PS. How do you spell tricksy er?
PPS. How do you spell tricksy?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I would suggest you move away from using Selection when working with your controls.

It does work and the alternatives can be a little more trixxy.:)

What type of controls are you actually dealing with here?
 
Upvote 0
I am currently working on a macro that will create a textbox and button in the active cell range when it runs. Everything is finally starting to come together but for some reason unknown to me the macro creates atleast two or three different fonts for the caption and inputs depending on what row I put them in. I guess this is not the most important thing in the world but it does make the projct look rather sloppy.
 
Upvote 0
Can you post the code you are using to create these controls?
 
Upvote 0
This is what I've got so far, (there are also some if statements above, and a codemodule bit below).


PHP:
Dim ole As OLEObject
 
    Set ole = ActiveSheet.OLEObjects.add(ClassType:="Forms.TextBox.1", Link:=False, _
        DisplayAsIcon:=False, Left:=ActiveCell.Left, Top:=ActiveCell.Top, _
        Width:=ActiveCell.Width, Height:=ActiveCell.Height)
        With ole
            .LinkedCell = ActiveCell.Address
            .Object.MultiLine = True
            .Object.ScrollBars = 2
            .Object.EnterKeyBehavior = True
            .Left = ActiveCell.Left
            .Top = ActiveCell.Top
            .Placement = xlMoveAndSize
            .PrintObject = True
        End With
 
    ActiveCell.Offset(0, -1).Select
 
    Set ole = ActiveSheet.OLEObjects.add(ClassType:="Forms.ToggleButton.1", Link:=False, _
        DisplayAsIcon:=False, Left:=ActiveCell.Left, Top:=ActiveCell.Top, _
        Width:=ActiveCell.Width, Height:=ActiveCell.Height)
 
        With ole
            .LinkedCell = ActiveCell.Address
            .Object.Caption = "New" & vbNewLine & "-->"
            .Left = ActiveCell.Left
            .Top = ActiveCell.Top
            .Placement = xlMoveAndSize
            .PrintObject = True
        End With
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,669
Members
448,977
Latest member
moonlight6

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top