Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • putexcel -- italicize a single word in a line of text, not the entire cell

    Hello,

    I am using putexcel to add a line of text to a table cell. I would like to italicize a single word in the text. I could not find a way to italicize a single word either in the do file editor or in the putexcel command. Does anyone know if this is possible? I demonstrate what I am trying to achieve below.

    Current code:

    putexcel A16 = "Note: See Methodology for description ..."

    Desired code:

    putexcel A16 = "Note: See Methodology for description ..."


    Thank you!
    Tom

  • #2
    I don't see that this is possible from the documentation.

    Comment


    • #3
      OK, thanks. I was wondering if someone knew of a nifty work around, Maybe I can do this with an Excel macro.

      Comment


      • #4
        On can make and run VBS code from Stata, The following may be adapted,
        Code:
        local EOL = char(10) + char(13)  
        
        local xlsx = "path/name.xlxs"
        
        #delim ;
        scalar VBS = `"Set obj = createobject("Excel.Application")`EOL'
        obj.visible=True`EOL'
        Set obj1 = obj.Workbooks.open("`xlsx'")`EOL'
        obj1.sheets(1).Range("A1").Characters(1,3).Font.Italic = True`EOL'
        obj1.Close`EOL'
        obj.Quit`EOL'
        Set obj1=Nothing`EOL'
        "';
        #delim cr
        
        di filewrite("italics.vbs", VBS, 1)  
                               
        shell italics.vbs
        erase italics.vbs

        Comment

        Working...
        X