# Thursday, April 17, 2008

Today, I was approached by someone with a request that sounded very simple.  She had a large Word document and she wanted to create an Excel spreadsheet in which each cell contained the name of a section in the Word document.  A hyperlink in each cell should open the Word document and navigate the user to the corresponding section.

Years ago, I did something similar using Office 97 or Office 2000, so I knew it was possible.

I opened the Word document and inserted a bookmark at the top of each section.  Inserting bookmarks in Word is pretty straightforward:

  1. Select the first line of the section
  2. From the menu/ribbon, select Insert Bookmark
  3. In the Bookmark dialog, type a name for that bookmark.

 

I became confused when I tried creating the hyperlinks in Excel.  Inserting a hyperlink in Excel hasn't changed much through the versions:

  1. Type some text in a cell
  2. Select that cell
  3. From the menu/ribbon, select Insert | Hyperlink
  4. Find and select the file to which you want to link.

This is where I became confused.  The "Insert Hyperlink" dialog contains a big button labeled "Bookmark".  Naturally I clicked this button to specify the bookmark within the Word document.  Unfortunately, clicking the button displayed an error.  According to Excel, Word documents don't support bookmarks, although my personal experience and the on-line help says that they do.

 

The secret is that you should not click the bookmark button in order to link to a bookmarked location in a Word document.  Rather, you should append the filename with the pound symbol ("#"), followed by the name of the bookmark to which you wish to link.  For example, I wanted to link to a bookmark named "Section1" in a document named "BigWordDoc.docx", so I entered "BigWordDoc.docx#Section1", as shown below.

Apparently, the "Bookmark" button is used for cells and defined names within an Excel document.

  

I'm not sure if Excel's "Insert Hyperlink" dialog has changed in the last few versions, but this strikes me as a flaw in the user interface.  The visual clues don't help me accomplish this task - they actually took me in a different direction.

Here is a working demo of an Excel spreadsheet with links to sections of a Word document: OfficeLinkDemo.zip (17.92 KB)

Thursday, April 17, 2008 9:56:20 PM (GMT Daylight Time, UTC+01:00)
# Wednesday, April 2, 2008
 #
 

A couple years ago, I had a chance to speak at a Day of .Net event in ann arbor, MI.  I enjoyed it so much that I signed up as an attendee at the same event last year.

Day of .Net is a single-day conference focused on Microsoft developer technologies.  It is free and takes place on a Saturday which makes it a lot easier to schedule for working professionals.  The speakers tend to be well-known technologists who live within a few hundred miles of the event.  I've been impressed with the lineup at the events I attended. 

The local flavor of the event also gives attendees a great chance to network with similar professionals in their geographic area. The focus tends to be on technology, rather than on strategy, so these things attract more hard-core developers and fewer CIOs and CTOs.

In the next few weeks, three Day of .Nets (or is it Days of .Net?) are scheduled within three hours of my home.  April 19 is the Central Ohio Day of .Net in Wilmington, OH (between Columbus and Dayton); May 10 is the West Michigan Day of .Net in Grand Rapids, MI; and May 17 is the Cleveland Day of .Net in Cleveland, OH.

Depending on my sons' basketball tournament schedules, I hope to attend two of these.  Click the links below for more information.

Central Ohio Day of .NET   WM Day of .Net May 10, 2008 - I'll be there!   Cleveland Day of .NET

Wednesday, April 2, 2008 12:41:48 PM (GMT Daylight Time, UTC+01:00)
# Tuesday, April 1, 2008
 #
 

Today is the first day of the fourth month, which means you should not believe anything you hear, read or see between now and midnight.

I found a great listing of the greatest April Fools pranks in history, based on cleverness and the number of people duped: http://www.museumofhoaxes.com/hoax/aprilfool/

Tuesday, April 1, 2008 11:05:14 PM (GMT Daylight Time, UTC+01:00)
# Wednesday, March 26, 2008
 #
 

If you haven't yet seen Josh Holmes and Steve Loethen's Internet show Code To Live, I recommend doing so.  Josh and Steve (mostly Josh) travel around the country interviewing people who are passionate about the technology on which they are working.  The video production is sometimes a bit lacking but the viewer gets a feel for the excitement people have for the work they are doing and the interviews often provide brief overviews of new technologies.

You can view this show at www.codetolive.net or http://channel9.msdn.com/shows/code_to_live

Wednesday, March 26, 2008 7:43:24 PM (GMT Standard Time, UTC+00:00)
# Thursday, March 20, 2008
 #
 

The 'Heroes Happen Here' launch was well worth my time.  Not only did we get a chance to see demos of Microsoft's newest products, I also got a chance to meet up with many of the most energetic developers in the midwest.  About 50 of us headed to Greektown after the event for an after-event event.  You can view my photos of the day here.

At the end of the day, everyone walked off with (among other things) a copy of Visual Studio 2008.  I was excited because I had spent most of the day following the Developers Track, which outlined the features of the new Visual Studio.  I'll be installing it this weekend. 

I especially like the fact that I can install VS 2008 and work on applications using older .Net frameworks.  Framework versions 2.0, 3.0 and 3.5 are all available.  This mitigates the risk of upgrading and it means I don't need to install multiple versions of Visual Studio.  I can write code that targest .Net Framework 2.0 but still take advantage of the improvements in the IDE, such as client-side debugging, stylesheet troubleshooting, and built-in Ajax support.

My customer has decided to upgrade to Visual Studio 2008 but defer the decision to upgrade the framework on which we have built our applications.

Here is a list of new features in Visual Studio 2008:  http://msdotnetsupport.blogspot.com/2007/11/22-new-features-of-visual-studio-2008.html
      

Thursday, March 20, 2008 7:15:04 PM (GMT Standard Time, UTC+00:00)
# Monday, March 17, 2008

Tomorrow is the big Heroes Happen Here event in Detroit.

Microsoft is launching new versions of Visual Studio, Windows Server and SQL Server.  I'm looking forward to seeing the new tools and how to utilize these tools in my projects. 

I believe the Detroit sessions are full but it may be possible to attend the event without attending the sessions.  It will be held from 8AM - 5PM at the Marriott in the Renaissance Center downtown.  You can get more information at http://www.microsoft.com/heroeshappenhere/default.mspx

Supposedly, Quick Solutions is sending up a busload of consultants from Columbus to the event.

 

Monday, March 17, 2008 3:21:29 PM (GMT Standard Time, UTC+00:00)
# Saturday, March 1, 2008

My son's basketball season ended Friday night in the District Finals.  The game couldn't have been closer.  Jackson High led by 9 points late in the game when Pioneer came storming back to force overtime.  But, in the end Jackson won in the extra session to capture the District crown.  Pioneer ended its season at 22-1 - a great record by any standard.  But Friday night all the boys were focused on the 1 loss.

The next day, Nick was back in the gym working on his jump shot.  I'm already excited about next year.

Saturday, March 1, 2008 7:29:03 PM (GMT Standard Time, UTC+00:00)
# Saturday, February 23, 2008

I delivered the web security presentation yesterday for my customer.  This is the same presentation I delivered as part of the DevCares event last week.  It went much better due to the fact that I secured a much better laptop for the presentation.  

The presentation materials are available here.

Saturday, February 23, 2008 2:30:46 PM (GMT Standard Time, UTC+00:00)
# Thursday, February 21, 2008

Scott Mitchell has an excellent article on 4GuysFromRolla.com about how to use ASP.Net to prompt a user to save changes before leaving a page.  It is part of a series he wrote back in 2004 but it is still relevant today.  The only change you should make today is that he calls methods of the Page class (IsStartupScriptRegistered, RegisterClientScriptBlock, RegisterArrayDeclaration) and these methods are depcrecated and replaced by the same methods in the Page.ClientScript class.

Scott's code initializes a client-side array with a list of inputs to monitor and the initial value of each input.  He then uses the onbeforeunload event to check if the data in any of these inputs has changed and displays a confirmation prompt if any data hase changed.  This event fires even if the user attempts to exit the form by closing the browser or clicking the brower's 'Back' button.

I liked Scott's approach so much that I took his public methods and moved them into a base class that inherits from System.Web.UI.Page and I inherit all my web pages from this class.  Now in each Page_Load, I can call methods of the base class to register controls that, if changed, will mark page data as dirty and prompt the user when he attempts to navigate away without saving.

I noticed that the "initial state" of controls were reset whenever a postback occurred, so I created a method "MarkDataAsDirty" that could be called when a control's "autopostback" fired but when the user is not finished entering data.  This sets a hidden form on the client that is checked in the onbeforeunload method to determine if data has changed.

I also made the methods public so they could be accessible to any user controls dropped on a page.  And I created the utility method RegisterForConfirmUnsavedChanges that registers the most common controls on the page using Scott's original methods.

I've included a sample ASP.NET web site in which every page inherits from a base page and methods of that base class are called to implement this functionality.

 

ConfirmSaveSite1.zip (9.51 KB)
Thursday, February 21, 2008 4:15:33 PM (GMT Standard Time, UTC+00:00)

Tonight's lunar eclipse was impressive.  I think I saw a full lunar eclipse when I was a boy but I don't remember it well.  This time I saw the moon with the full shadow of the Earth upon its face.  As I had heard, the light around the Earth's atmosphere cast a blood-led glow on the moon, giving it an eerie quality.  I managed a couple of photos despite not having a handy tripod.

 

Photo by David Giard

 

Thursday, February 21, 2008 3:18:54 AM (GMT Standard Time, UTC+00:00)