Skip to main content

CopySourceAsHTML for Visual Studio 2008 : Tips & Tricks

For a tech blogger who wants to show off a lot of codes , the gruesome process of Ctrl+C and Ctrl+V may not be of big help . Why? Because your blog may not be WYSIWYG and the pasted code just mess up your post . Then came CopySourceAsHTML for Visual Studio developers . Sleek and handy , just copy the code from your editor and paste it to your blog as HTML with all the CSS embedded in it to copy even the color schemes of the editor . Cool right? Well, the installer works only for Visual Studio 2005 !!!! And if your a developer working now on Visual Studio 2008 ( obviously I am ) , you dont have the capability to do that easily .

Just an hour ago I stumble on a site that allows you to download a CopySourceAsHTML compatible for Visual Studio 2008 . The bad news is that its not an installer but a zipped file containing 3 files that should be manually added to VS2008 . Here are the steps to make it run together with some test scenarios I did.

1. Download the Zip File on this SITE
2. Unzipped the file into [VS2008 Folder in my documents]\AddIns . If the folder does not exist , create it .
3. Open your Visual Studio 2008 then go to Tools|Options. On the Add in/Macro Security , add the path of the Add In folder you created in step #2 . Restart VS2008 .
4. After restart , double check if the CSAH is already added as an add-in by going to Tools | Add In Manager .
5. If you did all the steps correctly , the Copy As HTML item is already added in your context menu .

Testing Results :
Here are some things worth mentioning about CSAH for VS2008. Assuming we have the following code to be pasted in this blog .


1. If we copy lines 6 to 14 using the CSAH , we would not have any problem as shown below :
    6 namespace MVP
    7 {
    8     public interface ILogin
    9     {
   10         string UserID { get; set; }
   11         string Password { get; set; }
   12         bool RememberMe { get; set; }
   13     }
   14 }

2. But if copy only lines 8 to 13 , you would see slight problem at the first line as evident below:
    8 public interface ILogin
    9     {
   10         string UserID { get; set; }
   11         string Password { get; set; }
   12         bool RememberMe { get; set; }
   13     }

It is not a big issue but kinda ugly . You can fix this by adding spaces in the first line of the HTML generated code or you could probably start copying at line 7 as shown below :
    7 
    8     public interface ILogin
    9     {
   10         string UserID { get; set; }
   11         string Password { get; set; }
   12         bool RememberMe { get; set; }
   13     }

3. One more thing for blogspot users , make sure that the "strip line break" option is checked to avoid double spaces in your post.

Comments

Anonymous said…
There is no "Add in/Macro Security" after selecting Tools/Options. What did you do to get that?
Marvin said…
Hi,

the Add In/Macro Security is found under the Environment tree , just below the General item.

Thank you for visiting my blog.

trashVin

Popular posts from this blog

renaming default namespaces for VSTO projects in VS2008

So here is the scenario , you are starting a VSTO project and decided that your default namespace is ExcelAddInTesterApp . You created the project and started coding the project. After several days , your boss called and said "hey marvin , make use of this namespace OurCompany.ExcelAddInTesterApp , we have to add our company name to it got it?" . You get back to your machine thinking its just a simple property just like any project you've been working on. So you right clicked the VSTO project and hit properties . Boom! What the F@#$? The default namespace textbox is disabled!!!!



I've been through this and I googled for ways to do it and ended up with a blog from a Microsoft MVP telling me it can't be done because it is disabled. Then I thought of Refactoring, the beauty and grandeur of the renaming process. I selected the namespace and hit the refactor menu hoping that this would solve the problem . Unfortunately , it did not rather it displayed the message box …

this year

.. i will learn new things, perhaps play a new instrument or go back to school.
.. i will find beauty on the open source community.
.. i will read more books and listen to more music.
.. i will pen more poems and possibly write more songs.
.. i will go for new distances and discover new terrains.
.. i will continue to pile running miles to stay fit and healthy.
.. i will strive to be free and make myself available to unknown future.
.. i will go out of my shell more often and be socially more open.

.. i will continue to grow and go with the changes of time.
.. i will be more patient and hopeful to things that may not even be possible.
.. i will be a better son, brother and more importantly a better father.
.. i will be closer with the great beyond.

.. i will continue to repair , refactor and upgrade myself to become a better version of me.

Farewell NU107.5

As I write this blog,  millions of Filipino rock fanatics may have already known what happens after 12:00 midnight tonight. The only surviving station that caters to the rock genre will, sadly, be closing down and permanently signing off tonight. The news came to late to enjoy every second of what is left.  The sad news came to me the last week of October.  Being a follower of the station, I never believed it at first. But online resources would say the station really is nearing its demise.  With several minutes to go, it will be dead air.