+ Reply to Thread
Results 1 to 8 of 8

Bolding Part Of A Title By Code....

  1. #1
    Bob Barnes
    Guest

    Bolding Part Of A Title By Code....

    Here is a snippet of code I use when Opening a Workbook...

    ActiveSheet.ChartObjects("Chart 4").Activate
    ActiveChart.ChartTitle.Text = "ABC Total For " _
    & Worksheets("TheChart").Range("Title").Value
    ActiveChart.ChartArea.Select: ActiveChart.HasLegend = False

    Can I BOLD "ABC" above AND the entry that's stored in the Named
    Range "Title"???

    TIA - Bob


  2. #2
    Jon Peltier
    Guest

    Re: Bolding Part Of A Title By Code....

    Bob -

    Try this:

    Sub FormatTitle()
    Const sPREFIX1 As String = "ABC "
    Const sPREFIX2 As String = "Total For "

    ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    & Worksheets("TheChart").Range("TheTitle").Value
    ActiveChart.ChartTitle.Font.Bold = False
    ActiveChart.ChartTitle.Characters(1, Len(sPREFIX1)).Font.Bold = True
    ActiveChart.ChartTitle.Characters(1 + Len(sPREFIX1) +
    Len(sPREFIX2)).Font.Bold = True
    End Sub

    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com/
    _______

    Bob Barnes wrote:

    > Here is a snippet of code I use when Opening a Workbook...
    >
    > ActiveSheet.ChartObjects("Chart 4").Activate
    > ActiveChart.ChartTitle.Text = "ABC Total For " _
    > & Worksheets("TheChart").Range("Title").Value
    > ActiveChart.ChartArea.Select: ActiveChart.HasLegend = False
    >
    > Can I BOLD "ABC" above AND the entry that's stored in the Named
    > Range "Title"???
    >
    > TIA - Bob
    >


  3. #3
    Bob Barnes
    Guest

    Re: Bolding Part Of A Title By Code....

    Jon - THANK you.

    You are a Chart ACE.

    I was wondering if you would see & reply.

    Bob

    "Jon Peltier" wrote:

    > Bob -
    >
    > Try this:
    >
    > Sub FormatTitle()
    > Const sPREFIX1 As String = "ABC "
    > Const sPREFIX2 As String = "Total For "
    >
    > ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    > & Worksheets("TheChart").Range("TheTitle").Value
    > ActiveChart.ChartTitle.Font.Bold = False
    > ActiveChart.ChartTitle.Characters(1, Len(sPREFIX1)).Font.Bold = True
    > ActiveChart.ChartTitle.Characters(1 + Len(sPREFIX1) +
    > Len(sPREFIX2)).Font.Bold = True
    > End Sub
    >
    > - Jon
    > -------
    > Jon Peltier, Microsoft Excel MVP
    > Peltier Technical Services
    > Tutorials and Custom Solutions
    > http://PeltierTech.com/
    > _______
    >
    > Bob Barnes wrote:
    >
    > > Here is a snippet of code I use when Opening a Workbook...
    > >
    > > ActiveSheet.ChartObjects("Chart 4").Activate
    > > ActiveChart.ChartTitle.Text = "ABC Total For " _
    > > & Worksheets("TheChart").Range("Title").Value
    > > ActiveChart.ChartArea.Select: ActiveChart.HasLegend = False
    > >
    > > Can I BOLD "ABC" above AND the entry that's stored in the Named
    > > Range "Title"???
    > >
    > > TIA - Bob
    > >

    >


  4. #4
    Bob Barnes
    Guest

    Re: Bolding Part Of A Title By Code....

    Jon - I'm getting a runtime User-defined error for...

    ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    & Worksheets("TheChart").Range("TheTitle").Value

    TIA - Bob

    "Jon Peltier" wrote:

    > Bob -
    >
    > Try this:
    >
    > Sub FormatTitle()
    > Const sPREFIX1 As String = "ABC "
    > Const sPREFIX2 As String = "Total For "
    >
    > ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    > & Worksheets("TheChart").Range("TheTitle").Value
    > ActiveChart.ChartTitle.Font.Bold = False
    > ActiveChart.ChartTitle.Characters(1, Len(sPREFIX1)).Font.Bold = True
    > ActiveChart.ChartTitle.Characters(1 + Len(sPREFIX1) +
    > Len(sPREFIX2)).Font.Bold = True
    > End Sub
    >
    > - Jon
    > -------
    > Jon Peltier, Microsoft Excel MVP
    > Peltier Technical Services
    > Tutorials and Custom Solutions
    > http://PeltierTech.com/
    > _______
    >
    > Bob Barnes wrote:
    >
    > > Here is a snippet of code I use when Opening a Workbook...
    > >
    > > ActiveSheet.ChartObjects("Chart 4").Activate
    > > ActiveChart.ChartTitle.Text = "ABC Total For " _
    > > & Worksheets("TheChart").Range("Title").Value
    > > ActiveChart.ChartArea.Select: ActiveChart.HasLegend = False
    > >
    > > Can I BOLD "ABC" above AND the entry that's stored in the Named
    > > Range "Title"???
    > >
    > > TIA - Bob
    > >

    >


  5. #5
    Jon Peltier
    Guest

    Re: Bolding Part Of A Title By Code....

    1. Is a chart selected?
    2. Does the selected chart have a title? I've inserted a line in the new
    version of the macro, which should have been there anyway, just in case.:

    Sub FormatTitle()
    Const sPREFIX1 As String = "ABC "
    Const sPREFIX2 As String = "Total For "

    ActiveChart.HasTitle = True
    ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    & Worksheets("TheChart").Range("TheTitle").Value
    ActiveChart.ChartTitle.Font.Bold = False
    ActiveChart.ChartTitle.Characters(1, Len(sPREFIX1)).Font.Bold = True
    ActiveChart.ChartTitle.Characters(1 + Len(sPREFIX1) +
    Len(sPREFIX2)).Font.Bold = True
    End Sub

    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com/
    _______



    Bob Barnes wrote:

    > Jon - I'm getting a runtime User-defined error for...
    >
    > ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    > & Worksheets("TheChart").Range("TheTitle").Value
    >
    > TIA - Bob
    >
    > "Jon Peltier" wrote:
    >
    >
    >>Bob -
    >>
    >>Try this:
    >>
    >>Sub FormatTitle()
    >> Const sPREFIX1 As String = "ABC "
    >> Const sPREFIX2 As String = "Total For "
    >>
    >> ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    >> & Worksheets("TheChart").Range("TheTitle").Value
    >> ActiveChart.ChartTitle.Font.Bold = False
    >> ActiveChart.ChartTitle.Characters(1, Len(sPREFIX1)).Font.Bold = True
    >> ActiveChart.ChartTitle.Characters(1 + Len(sPREFIX1) +
    >>Len(sPREFIX2)).Font.Bold = True
    >>End Sub
    >>
    >>- Jon
    >>-------
    >>Jon Peltier, Microsoft Excel MVP
    >>Peltier Technical Services
    >>Tutorials and Custom Solutions
    >>http://PeltierTech.com/
    >>_______
    >>
    >>Bob Barnes wrote:
    >>
    >>
    >>>Here is a snippet of code I use when Opening a Workbook...
    >>>
    >>>ActiveSheet.ChartObjects("Chart 4").Activate
    >>>ActiveChart.ChartTitle.Text = "ABC Total For " _
    >>>& Worksheets("TheChart").Range("Title").Value
    >>>ActiveChart.ChartArea.Select: ActiveChart.HasLegend = False
    >>>
    >>>Can I BOLD "ABC" above AND the entry that's stored in the Named
    >>>Range "Title"???
    >>>
    >>>TIA - Bob
    >>>

    >>


  6. #6
    Bob Barnes
    Guest

    Re: Bolding Part Of A Title By Code....

    Jon - It STILL gives Error 1004 = User-defined error.

    Here's my snippet...
    Sheets("TheChart").Select
    ActiveSheet.ChartObjects("Chart 4").Activate
    Const sPREFIX1 As String = "ABC "
    Const sPREFIX2 As String = "Total For "
    ActiveChart.HasTitle = True
    ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    & Worksheets("TheChart").Range("TheTitle").Value

    It fails at the "last line" above..

    TIA - Bob

    "Jon Peltier" wrote:

    > 1. Is a chart selected?
    > 2. Does the selected chart have a title? I've inserted a line in the new
    > version of the macro, which should have been there anyway, just in case.:
    >
    > Sub FormatTitle()
    > Const sPREFIX1 As String = "ABC "
    > Const sPREFIX2 As String = "Total For "
    >
    > ActiveChart.HasTitle = True
    > ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    > & Worksheets("TheChart").Range("TheTitle").Value
    > ActiveChart.ChartTitle.Font.Bold = False
    > ActiveChart.ChartTitle.Characters(1, Len(sPREFIX1)).Font.Bold = True
    > ActiveChart.ChartTitle.Characters(1 + Len(sPREFIX1) +
    > Len(sPREFIX2)).Font.Bold = True
    > End Sub
    >
    > - Jon
    > -------
    > Jon Peltier, Microsoft Excel MVP
    > Peltier Technical Services
    > Tutorials and Custom Solutions
    > http://PeltierTech.com/
    > _______
    >
    >
    >
    > Bob Barnes wrote:
    >
    > > Jon - I'm getting a runtime User-defined error for...
    > >
    > > ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    > > & Worksheets("TheChart").Range("TheTitle").Value
    > >
    > > TIA - Bob
    > >
    > > "Jon Peltier" wrote:
    > >
    > >
    > >>Bob -
    > >>
    > >>Try this:
    > >>
    > >>Sub FormatTitle()
    > >> Const sPREFIX1 As String = "ABC "
    > >> Const sPREFIX2 As String = "Total For "
    > >>
    > >> ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    > >> & Worksheets("TheChart").Range("TheTitle").Value
    > >> ActiveChart.ChartTitle.Font.Bold = False
    > >> ActiveChart.ChartTitle.Characters(1, Len(sPREFIX1)).Font.Bold = True
    > >> ActiveChart.ChartTitle.Characters(1 + Len(sPREFIX1) +
    > >>Len(sPREFIX2)).Font.Bold = True
    > >>End Sub
    > >>
    > >>- Jon
    > >>-------
    > >>Jon Peltier, Microsoft Excel MVP
    > >>Peltier Technical Services
    > >>Tutorials and Custom Solutions
    > >>http://PeltierTech.com/
    > >>_______
    > >>
    > >>Bob Barnes wrote:
    > >>
    > >>
    > >>>Here is a snippet of code I use when Opening a Workbook...
    > >>>
    > >>>ActiveSheet.ChartObjects("Chart 4").Activate
    > >>>ActiveChart.ChartTitle.Text = "ABC Total For " _
    > >>>& Worksheets("TheChart").Range("Title").Value
    > >>>ActiveChart.ChartArea.Select: ActiveChart.HasLegend = False
    > >>>
    > >>>Can I BOLD "ABC" above AND the entry that's stored in the Named
    > >>>Range "Title"???
    > >>>
    > >>>TIA - Bob
    > >>>
    > >>

    >


  7. #7
    Bob Barnes
    Guest

    Re: Bolding Part Of A Title By Code....

    Jon - It appears to be WORKING now.

    Perhaps, when stepping thru (testing the Access-to-Excel
    Automation), something caused the Error 1004. It's OK now.

    THANK you - Bob

    "Bob Barnes" wrote:

    > Jon - It STILL gives Error 1004 = User-defined error.
    >
    > Here's my snippet...
    > Sheets("TheChart").Select
    > ActiveSheet.ChartObjects("Chart 4").Activate
    > Const sPREFIX1 As String = "ABC "
    > Const sPREFIX2 As String = "Total For "
    > ActiveChart.HasTitle = True
    > ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    > & Worksheets("TheChart").Range("TheTitle").Value
    >
    > It fails at the "last line" above..
    >
    > TIA - Bob
    >
    > "Jon Peltier" wrote:
    >
    > > 1. Is a chart selected?
    > > 2. Does the selected chart have a title? I've inserted a line in the new
    > > version of the macro, which should have been there anyway, just in case.:
    > >
    > > Sub FormatTitle()
    > > Const sPREFIX1 As String = "ABC "
    > > Const sPREFIX2 As String = "Total For "
    > >
    > > ActiveChart.HasTitle = True
    > > ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    > > & Worksheets("TheChart").Range("TheTitle").Value
    > > ActiveChart.ChartTitle.Font.Bold = False
    > > ActiveChart.ChartTitle.Characters(1, Len(sPREFIX1)).Font.Bold = True
    > > ActiveChart.ChartTitle.Characters(1 + Len(sPREFIX1) +
    > > Len(sPREFIX2)).Font.Bold = True
    > > End Sub
    > >
    > > - Jon
    > > -------
    > > Jon Peltier, Microsoft Excel MVP
    > > Peltier Technical Services
    > > Tutorials and Custom Solutions
    > > http://PeltierTech.com/
    > > _______
    > >
    > >
    > >
    > > Bob Barnes wrote:
    > >
    > > > Jon - I'm getting a runtime User-defined error for...
    > > >
    > > > ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    > > > & Worksheets("TheChart").Range("TheTitle").Value
    > > >
    > > > TIA - Bob
    > > >
    > > > "Jon Peltier" wrote:
    > > >
    > > >
    > > >>Bob -
    > > >>
    > > >>Try this:
    > > >>
    > > >>Sub FormatTitle()
    > > >> Const sPREFIX1 As String = "ABC "
    > > >> Const sPREFIX2 As String = "Total For "
    > > >>
    > > >> ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    > > >> & Worksheets("TheChart").Range("TheTitle").Value
    > > >> ActiveChart.ChartTitle.Font.Bold = False
    > > >> ActiveChart.ChartTitle.Characters(1, Len(sPREFIX1)).Font.Bold = True
    > > >> ActiveChart.ChartTitle.Characters(1 + Len(sPREFIX1) +
    > > >>Len(sPREFIX2)).Font.Bold = True
    > > >>End Sub
    > > >>
    > > >>- Jon
    > > >>-------
    > > >>Jon Peltier, Microsoft Excel MVP
    > > >>Peltier Technical Services
    > > >>Tutorials and Custom Solutions
    > > >>http://PeltierTech.com/
    > > >>_______
    > > >>
    > > >>Bob Barnes wrote:
    > > >>
    > > >>
    > > >>>Here is a snippet of code I use when Opening a Workbook...
    > > >>>
    > > >>>ActiveSheet.ChartObjects("Chart 4").Activate
    > > >>>ActiveChart.ChartTitle.Text = "ABC Total For " _
    > > >>>& Worksheets("TheChart").Range("Title").Value
    > > >>>ActiveChart.ChartArea.Select: ActiveChart.HasLegend = False
    > > >>>
    > > >>>Can I BOLD "ABC" above AND the entry that's stored in the Named
    > > >>>Range "Title"???
    > > >>>
    > > >>>TIA - Bob
    > > >>>
    > > >>

    > >


  8. #8
    Jon Peltier
    Guest

    Re: Bolding Part Of A Title By Code....

    Step by step...

    Is there a worksheet named "TheChart"?
    Does it contain a range named "TheTitle"?
    Insert a few temporary lines:

    MsgBox sPREFIX1
    MsgBox sPREFIX2
    MsgBox Worksheets("TheChart").Range("TheTitle").Value

    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com/
    _______


    Bob Barnes wrote:

    > Jon - It STILL gives Error 1004 = User-defined error.
    >
    > Here's my snippet...
    > Sheets("TheChart").Select
    > ActiveSheet.ChartObjects("Chart 4").Activate
    > Const sPREFIX1 As String = "ABC "
    > Const sPREFIX2 As String = "Total For "
    > ActiveChart.HasTitle = True
    > ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    > & Worksheets("TheChart").Range("TheTitle").Value
    >
    > It fails at the "last line" above..
    >
    > TIA - Bob
    >
    > "Jon Peltier" wrote:
    >
    >
    >>1. Is a chart selected?
    >>2. Does the selected chart have a title? I've inserted a line in the new
    >>version of the macro, which should have been there anyway, just in case.:
    >>
    >>Sub FormatTitle()
    >> Const sPREFIX1 As String = "ABC "
    >> Const sPREFIX2 As String = "Total For "
    >>
    >> ActiveChart.HasTitle = True
    >> ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    >> & Worksheets("TheChart").Range("TheTitle").Value
    >> ActiveChart.ChartTitle.Font.Bold = False
    >> ActiveChart.ChartTitle.Characters(1, Len(sPREFIX1)).Font.Bold = True
    >> ActiveChart.ChartTitle.Characters(1 + Len(sPREFIX1) +
    >>Len(sPREFIX2)).Font.Bold = True
    >>End Sub
    >>
    >>- Jon
    >>-------
    >>Jon Peltier, Microsoft Excel MVP
    >>Peltier Technical Services
    >>Tutorials and Custom Solutions
    >>http://PeltierTech.com/
    >>_______
    >>
    >>
    >>
    >>Bob Barnes wrote:
    >>
    >>
    >>>Jon - I'm getting a runtime User-defined error for...
    >>>
    >>>ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    >>>& Worksheets("TheChart").Range("TheTitle").Value
    >>>
    >>>TIA - Bob
    >>>
    >>>"Jon Peltier" wrote:
    >>>
    >>>
    >>>
    >>>>Bob -
    >>>>
    >>>>Try this:
    >>>>
    >>>>Sub FormatTitle()
    >>>> Const sPREFIX1 As String = "ABC "
    >>>> Const sPREFIX2 As String = "Total For "
    >>>>
    >>>> ActiveChart.ChartTitle.Text = sPREFIX1 & sPREFIX2 _
    >>>> & Worksheets("TheChart").Range("TheTitle").Value
    >>>> ActiveChart.ChartTitle.Font.Bold = False
    >>>> ActiveChart.ChartTitle.Characters(1, Len(sPREFIX1)).Font.Bold = True
    >>>> ActiveChart.ChartTitle.Characters(1 + Len(sPREFIX1) +
    >>>>Len(sPREFIX2)).Font.Bold = True
    >>>>End Sub
    >>>>
    >>>>- Jon
    >>>>-------
    >>>>Jon Peltier, Microsoft Excel MVP
    >>>>Peltier Technical Services
    >>>>Tutorials and Custom Solutions
    >>>>http://PeltierTech.com/
    >>>>_______
    >>>>
    >>>>Bob Barnes wrote:
    >>>>
    >>>>
    >>>>
    >>>>>Here is a snippet of code I use when Opening a Workbook...
    >>>>>
    >>>>>ActiveSheet.ChartObjects("Chart 4").Activate
    >>>>>ActiveChart.ChartTitle.Text = "ABC Total For " _
    >>>>>& Worksheets("TheChart").Range("Title").Value
    >>>>>ActiveChart.ChartArea.Select: ActiveChart.HasLegend = False
    >>>>>
    >>>>>Can I BOLD "ABC" above AND the entry that's stored in the Named
    >>>>>Range "Title"???
    >>>>>
    >>>>>TIA - Bob
    >>>>>
    >>>>


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1