VBA code for creating new text style

Posted on 2009-12-29
Last Modified: 2013-12-04
I would like to have code for creating a new text style call "Bold" and having the same properties as the text style "Standard" but having bold instead of regular.

Question by:Saqib Husain, Syed
    1 Comment
    LVL 14

    Accepted Solution

    This will creat a new text style with all of the same attributes as the text style Standard. Then I change the bold to true and the name to BOLD. Ths issue I have is as long as I use the text style without bringing up the dialog box it works fine. If you open the dialog box it doesn't seem to pick up the bold. If this is unacceptable i may try to use lisp to do the dirty part.


    Sub MakeBold()
        Dim NewStl As AcadTextStyle, Asd As AcadTextStyle
        Dim typeFace As String
        Dim Bold As Boolean
        Dim Italic As Boolean
        Dim charSet As Long
        Dim PitchandFamily As Long
        Const TMPF_TRUETYPE = &H4
        For Each Asd In ThisDrawing.TextStyles
            If Asd.Name = "Standard" Then
                Asd.GetFont typeFace, Bold, Italic, charSet, PitchandFamily
            End If
        Set NewStl = ThisDrawing.TextStyles.Add("BOLD")
        If Not Bold Then Bold = True
        NewStl.SetFont typeFace, Bold, Italic, charSet, TMPF_TRUETYPE
        ThisDrawing.ActiveTextStyle = NewStl
    End Sub

    Open in new window


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Autocad 2011 all work lost. 6 193
    Autocad auto-save option slow 3 43
    visio file 1 54
    autocad 2015 hardware suggestions 47 69
    Our company has proprietary drawing files that we do not give to our customers for final documentation. Our customers now require that we give them these drawings. They understand that they are proprietary and do not require them to be in AutoCAD bu…
    If, like me, you find yourself repeatedly and tediously joining many segments (lines, arcs) in other people's drawings back into polylines that can be used more effectively in Computer Aided Machining and Laser Cutting, then this article is for you!…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now