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 :
    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.


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

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

Thank you for visiting my blog.


Popular posts from this blog

Hiding Unwanted Python Folders and Files in Visual Studio Code

Visual Studio Code is a universal editor and pretty good at it. However, the explorer view maybe cluttered with the automatically generated folders and files confusing developers. Python is no different. Below are example files and folders generated by Python.

The __pycache__ folder and *.pyc files  are totally unnecessary to the developer. To hide these files from the explorer view, we need to edit the settings.json for VSCode. Add the folder and the files as shown below:
Copy and paste the lines below :


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 …

Getting Started with Stateless : A Lightweight Workflow Library Alternative for .NET

A year ago, I was looking for a simple workflow manager for a project I was working. Its a medium sized application that involves tracking the state of assets in the system. Back in 2008, Microsoft (MS) introduced new technologies along with the release of Visual Studio 2008: Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), and Windows Workflow Foundation(WF). Having worked in a company utilizing mostly MS products for development, my first option was to go with WF. After doing some time reading and studying the library, I paused and decided it was too complex for my requirement. Using WF would be an overkill and the fact that it has, a rather, steep learning curve, there has to be another option. My mind toyed with the idea of developing a simple workflow library myself. It would be a learning experience but it might end up consuming a lot of time.

Why reinvent the wheel? So I started querying the internet for a better solution. I stumbled upon Stateless