Computer How to ? Interesting MS Office Programming tricks Techniques Tricks Useful

Create an HTML Editor Using Excel VBA

This is a very very useful trick for creating a beautiful HTML editor using MS Excel. You will feel very happy as you are going to create a small functional software with some easy steps. In the application there will be a textbox. When you will write some HTML in the text box, the corresponding view will be instantly reflected in the right side browser. Don't worry, my tutorial will be completely easy. Just go through the following steps carefully.

Verifying the presence of developer tab

  • Open MS excel and just check whether the Developer tab is visible in your excel or not. (Developer tab is hidden by default)

    Developer Tab
  • If it is visible then OK otherwise you need enable its visibility. To make it enable just click on the round Microsoft button present at the top left, a small window will open where you will see a button called Excel options, click on it to open a large pop up window. In that window you will find a check box called Show Developer Tab in the ribbon. Make it checked and click OK to show a Developer tab.

Adding required Objects

  • Now you have to add the following components to the excel.
  • Two Buttons, One Textbox and One Microsoft Web Browser.
  • To add the Web Browser, click on the icon as shown in the figure. A small pop up window will open where you need to select MS Web browser and click OK.
  • After you create all, there will be total 4 objects in your excel. You can change their size and position as per your requirement. Make the Web Browser's size little large so that everything will be clearly visible.
    Form Control

Changing the properties of the Objects

Right click on the Textbox and click on properties. Then set only the following properties.

  • Border Style-1-fmBorderStyleSingle
  • Enter Key Behaviour-True
  • Multiline-True
  • Scrollbar-3-fmScrollBarBoth
  • TabKeyBehaviour-True
  • WordWrap-False
  • Then Right click on the Command Button1 on your Excel and click on properties. Then set only the following properties.
  • Caption-"Open"
  • Then Right click on the Command Button2 on your Excel and click on properties. Then set only the following properties.
  •  Caption-"Save As"

Creating the VB Code

  • Now you need to copy and paste a small VB code. You don't have to write anything. The code is ready for you.
  • Press the View Code button present under the Developer Tab or press alt+f11 to open the visual basic editor.
  • In the visual basic editor if any code is previously present then delete them. Then copy and paste the following code in the editor.

  • Now you are almost done. Go to Excel again.

How to save the Excel File

  • To save the file click on the Microsoft button present at the top left → Click on Save As  Excel-Macro Enabled Workbook.
  • Then close the Excel file 

 How to run the application

  • To run the application open the file that you have saved right now → Go to Developer Tab → Macro Security → Enable All Macros.
  • If you will not enable the Macro, your program will not run. So any how you have to make it enable.

A very similar post you may also like to see :   Create an instant HTML editor with just 10 lines