locked
VBA Macro created in Excel Workbook RRS feed

  • Question

  • Hello,

    I'm a real novice with VB all together and I've been given a task for work to do that requires me to change some code.  I hope someone can assist.  I have an Excel spreadsheet with macro's in it.  One of the macro takes information out of excel and updates a powerpoint presentation.  Right now it updates status fields on the ppt with colors, i.e, R - Red, G - Green, etc.  I need to change that from updating the fields on the ppt with colors to just text.  The code reads:

    sl.Shapes(taskfield).Fill.Transparency = 0#
    sl.Shapres(taskfield).TextFrame.TextRange.Font.Color.RGB = RGB(0,0,0)

    If taskstatus = "R" Then
      sl.Shapes(taskfield).Fill.ForeColor.RGB = RGB(255, 0, 0)
      sl.Shapes(taskfield).TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
    Else
      sl.Shapes(taskfield).Fill.Visible = msoFalse
    End If

    I need to change it to read the text "At Risk" instead of "R" and place that text in the ppt text field.  I hope that makes sense to anyone that can assist.  Thank you

    Tony
    Monday, December 22, 2008 6:23 PM

Answers

  • Hi

    do you want to change colors as well as text of the textframe?
    if you do so, plz try this:

    If taskstatus = "At Risk" Then
      sl.Shapes(taskfield).Fill.ForeColor.RGB = RGB(255, 0, 0)
      sl.Shapes(taskfield).TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
      sl.Shapes(taskfield).TextFrame.TextRange.Text = "At Risk"
    Else
    ...

    HTH

    sjoo
    • Marked as answer by JstWalt Tuesday, December 23, 2008 4:23 PM
    Tuesday, December 23, 2008 1:07 AM

All replies

  • Hi

    do you want to change colors as well as text of the textframe?
    if you do so, plz try this:

    If taskstatus = "At Risk" Then
      sl.Shapes(taskfield).Fill.ForeColor.RGB = RGB(255, 0, 0)
      sl.Shapes(taskfield).TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
      sl.Shapes(taskfield).TextFrame.TextRange.Text = "At Risk"
    Else
    ...

    HTH

    sjoo
    • Marked as answer by JstWalt Tuesday, December 23, 2008 4:23 PM
    Tuesday, December 23, 2008 1:07 AM
  • Hi and thank you for the reply.

    No I don't want to change colors, just post text with no color. 

    V r

    Tony
    Tuesday, December 23, 2008 12:16 PM
  • I see, JstWalt!

    In case of changing only text, you should drop the first two lines
    and use the bold sentence(sl.Shapes(taskfield).TextFrame.TextRange.Text = "At Risk") within the THEN clause.

    Wednesday, December 24, 2008 12:17 AM