Posts

VBA Macro to copy Excel data into MS Word table

The below code will help you to copy the MS Excel data into MS Word. The main thing to note here is, the Excel data is copied into Word in a table format. This is a very basic VBA code, you can extend this to add other features. To add this code to your excel, Open VBA editor in Excel or you can press F11. Insert a module, paste this code. Come back to excel by pressing F11 again. Under macros you can see the name of subroutine 'CopyFromExcelToWord' appearing, this is your macro. Sub CopyFromExcelToWord()    Dim objWord    Dim objDoc    Dim objRange    Dim total_rows    Dim total_cols    Dim objTable    Dim tmp_row    Dim tmp_col     total_rows = Cells(1, 10).Value     total_cols = Cells(2, 10).Value     Set objWord = CreateObject("Word.Application")   Set objDoc = objWord.Documents.Add   Set objRange = objDoc.Range   objWord.Visible = True ...

How to create MS Word document automatically with Text file

This VBA code will help you to import data from a text file and insert it into the MS word document. This is useful when you have to create a report or formats in MS Word format, reading the data from a text file. The VBA code can be extended import extra data from the text file, and also you can add additional format as per your needs. Please note that VBA macros can cause harm to your computer. First, open them in a disabled mode. To disable macros, to Developer tab, select macro security and then select Macro settings on the left side pane. In the right pane, select the second radio button, 'Disable all macros with notification'. The second option is better because it will notify you if there are any macros associated with your file. So you will not miss any document features that may be available after running a macro. But you can decide whether to allow the macros to run or not. Please click on the below link to download the MS Word Template file. You can also download...

MS Excel Currency converter VBA code

To convert numbers into text, there is no  builtin function in MS Excel as of now. Using the below VBA code you can overcome this issue. There are situations like writing a cheque leaf, printing a rent agreement, or writing contract documents that may require printing the transaction amount in the text. Make use of this code to convert numbers into text automatically.  Copy and paste this VBA code into your Excel VBA editor module. Or Insert an empty module and paste this code. Attribute VB_Name = "Module1" 'Attribute VB_Name = "Module2" ' ****  Author          : Krishna S ' ****  Tittle          : Converting Hindu Arabic Currency(Indian System) to Words ' ****  Copyright Owner : Krishna S ' ****  Description     : This utility converts currencies in Indian numbering system to words. ' ****  Limitations     : Converts only upto 10,00,00,000( Ten Crores) Function C...