• Home
  • About
  • Contact
  • Projects
« Media Center and the command line
VB and Resource Files (part 2) »

Excel 2007, Defined Name Comments, and the null string malady

Posted by admin on May 2, 2007 – 5:36 pm      
Filed under Metadata, Office

New to the Excel 2007 object model is the Comments property of the Name object.

The Name object itself has been around since Excel 2000 and possibly before, but the Comment property is a handy new development.

I like Comment properties personally. Any object model representing items such as this would benefit from a property where you can stash whatever info is pertinent. Take, for instance, the venerable tag property of VB controls. Of course, these things can be misused, but then, is there anything that can’t be misused in the wrong hands?

Anyway, comments like this are great, but they also represent potentially sensitive information that you might not want to reveal to third parties, especially in this case, because the comments themselves are persisted to the workbook. Excel 2007 has a nifty Document Inspector you can use to remove these comments, which is nice. However, when you run the inspector, it simply says that there were comments detected, would you like to delete them? Nice, but not terribly informative.

Retrieving the comments on a Name is not too hard.

cmt = ExcelApp.ActiveWorkbook.Names(1).Comment                                                   

But, when you go to clear the comment:

ExcelApp.ActiveWorkbook.Names(1).Comment = ""

Nothing happens…

Excel, and Word, and PowerPoint for that matter, all seem to be afflicted by this particular “a blank string doesn’t really count” malady in one way or another. Setting the Creation Date, for example, or the Username or UserInitials all seem to have similar problems with being set to a null string.

The solution, though not ideal, isn’t too terribly bad either, I suppose.

ExcelApp.ActiveWorkbook.Names(1).Comment = " "

Yes, that’s right, just set it to a space, instead of a null string.

It’d be interesting to see the code responsible for implementing these properties, just to see how it could be coded such that a null string is ignored like this. It seems like it just couldn’t have been intentional.

And just for the record, passing an actual null char doesn’t work either, so it doesn’t appear to be a “C string/BSTR related” issue.

Comments RSS Feed   Post a comment   Trackback URL   Share on Twitter   Share on Facebook

One Comment

  1. Sid Meier's says:
    October 14, 2014 at 1:42 pm

    The direction of the life of world humanity takes a positive turn. The balance
    between the spiritual and physical then is broken. I could feel the raw
    energy move past my optic nerves and settle into my cortical
    structures.

    Reply to this comment

Post a Comment

Click here to cancel reply.

Your email is never published nor shared. Required fields are marked *

*
*

  • Subscribe

  • Recent Posts

    • Easy Command Line Bookmarks
    • Teams, Remote Desktop, and a Jumpy Mouse
    • Repairing a DDRGame Dance Pad
    • Running Visual Studio as Admin Without the UAC prompts
    • Laying Asphalt
  • Recent Comments

    • Laying Asphalt — darinhiggins.com on Hacking Hack
    • Hacking Hack — darinhiggins.com on Best Programming Font
    • admin on Authoring VB6 IDE Addins in VB.net
    • admin on Launching into a Zoom Meeting directly from a Windows Shortcut
    • Daniel on Launching into a Zoom Meeting directly from a Windows Shortcut
  • Archives

    • February 2025
    • August 2023
    • June 2023
    • February 2023
    • November 2022
    • October 2022
    • August 2022
    • May 2021
    • December 2020
    • November 2020
    • September 2020
    • August 2020
    • April 2020
    • July 2018
    • June 2014
    • February 2013
    • December 2012
    • September 2012
    • August 2012
    • July 2012
    • June 2012
    • May 2012
    • April 2012
    • March 2012
    • February 2012
    • January 2012
    • November 2011
    • October 2011
    • September 2011
    • August 2011
    • July 2011
    • June 2011
    • May 2011
    • April 2011
    • March 2011
    • February 2011
    • January 2011
    • November 2010
    • October 2010
    • September 2010
    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
    • September 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • April 2007
    • January 2007
  • Categories

    • .NET
    • ActiveX
    • amBX
    • Apophysis
    • Arcade
    • ASP
    • AutoHotKey
    • Blogging
    • Cisco
    • Code Garage
    • CSS
    • Cuckoo Clocks
    • dasBlog
    • DMS
    • DOCSOpen
    • EMail
    • Error Handling
    • Expression Blend
    • Firefox
    • Font
    • Fonts
    • Fractals
    • Frets On Fire
    • Games
    • Guitar
    • Hack of the Day
    • Hardware
    • Helicopters
    • Hiring
    • Icons
    • Installations
    • Javascript
    • KnockOut
    • Languages
    • log4net
    • Maps/GIS
    • Media
    • Metadata
    • Misc
    • MP3s
    • MSBuild
    • Networking
    • nuget
    • Office
    • p/Invoke
    • Panoramas
    • PDF
    • Phones
    • Photography
    • Pool
    • Python
    • Rants
    • RawMouse
    • Regular Expressions
    • Resource Files
    • Roomba
    • Security
    • Software Architecture
    • SQL
    • Stepmania
    • Subversion
    • Telecommuting
    • Terragen
    • Text Editors
    • Tivo
    • Troubleshooting
    • Tweaks
    • TypeLibs
    • Uncategorized
    • Utilities
    • VB Feng Shui
    • VB6
    • Version Control
    • Vista
    • Visual Studio
    • VSTO
    • Web
    • Windows 7
    • Windows Phone 7
    • WindowsMediaPlayer
    • Word
    • WordPress
    • WPF
    • XML
  • Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org


Content © darinhiggins.com and Darin Higgins. Proudly powered by WordPress. To bookmark this site, press Control+D.

"StarGate" theme by Darin Higgins based on "Black Hat" by Nicki Faulk. For best results, please view with Firefox.   [ Log in ]
Comment antispam by