Stupid Trick #1: Copying a Message Box to the Clipboard

Published 06 March 05 08:45 AM | chris 

Charles turned me on to a nice little trick to use when developing. I also have to say I feel stupid, as I could have used this tip for years.

Stupid Trick #1: If you use the MsgBox function to create a message box, did you know you can copy and paste the text from the MsgBox window? For example, I have the following code in Excel:

  MsgBox "Hi Chris, You can copy and paste me."

 When I run this code I get the following message box in Excel:

     Copyandpastdialog

Then I press the windows copy keyboard shortcut (CTRL+C) and now the following is in the clipboard:

  ---------------------------
  Microsoft Excel
  ---------------------------
  Hi Chris, You can copy and paste me.
  ---------------------------
  OK  
  ---------------------------

This technique basically works in any Office application. Why is this useful? Ok, this won’t change my world. But when testing code, its common to use message boxes to send yourself a message about what  is happening under the hood or especially for error handling messages. This is nice because during testing you can copy and paste the messages to have a full record of what broke so you can fix it later.

Thanks Charles!

Comments

No Comments
Anonymous comments are disabled