Facebook

test

How To Create Automated Student Mark Sheet!!



In this article, we will discover ways to automate Microsoft Word from Excel with the assist of Visual Basic Language. To analyze the Word Automation, we will do not forget a totally practical example i.E. Creating Student’s Mark Sheet in MS Word from Excel Table.

If you find that you are continuously copying and pasting information into Microsoft Word in a particular format then you may use the code and logic, which we are going to use here.

Before walking via the macro, it is critical to go over some steps.

Please create a Word file for Students mark sheet as mentioned in the below image or download the template used in this tutorial.

Once you create or download the word file, you need to create bookmarks tagging the location where you want your Excel data to be copied.

In the current word file, we need total 17 bookmarks to transfer Student Name, Registration Number, Program Name, Examination Date, Grade, Statistics Marks, Statistics Result, Excel Marks, Excel Result, VBA Marks, VBA Result, SQL Marks, SQL Result, Power BI Mark, Power BI Result, Grand Total Marks and Percentage.

Insert Bookmarks
Bookmark Fields Highlighted with to create a bookmark in a Word document, region your cursor where you want the bookmark then visit Insert Tab and pick Bookmark to be had beneath the Links group. This will open the Bookmark dialog box wherein you could provide the name of the bookmark and click on the Add button.

Let us follow the same step as mentioned above and create a bookmark for ‘Name’.

Steps to Insert Bookmarks
Steps to Insert Bookmarks

In the same way, just create the rest of the 16 Bookmarks required for this automation.

Please use the below-mentioned Bookmarks name. We will use these names in VBA code while doing automation.

  1. Name
  2. Registration_Number
  3. Program_Name
  4. Examination_Date
  5. Grade
  6. Statistics_Marks
  7. Statistics_Result
  8. Excel_Marks
  9. Excel_Result
  10. VBA_Marks
  11. VBA_Result
  12. SQL_Marks
  13. SQL_Result
  14. PowerBI_Marks
  15. PowerBI_Result
  16. GrandTotal
  17. Percentage

Once, you create all the Bookmarks save the word file in the name ‘Marksheet Template.docx‘ at the same location where you are going to keep MS Excel file. Now, close the file after saving it.

Now, open the Excel Application and create a blank worksheet. Save the file with the name ‘Automating Word from Excel.xlsm’ in the same folder where you have kept Word file.

Create the table with the required data as mentioned in the below image. Please keep the cell reference as it is otherwise your code will not work (if you are following the same example).

Now, insert a rounded rectangle and give the caption as ‘Prepare Marksheet’. We will assign macro on this button to create a mark sheet once coding will be done.

Prepare Excel File and Table
Prepare Excel File and Table

Let us jump to Visual Basic Application Window to start coding. To open VBA Window, go to Developer Tab and Click on Visual Basic button available under Code group.

Go To Visual Basic Window
Go To Visual Basic Window

In the Visual Basic window, insert a blank module. A module would be required to write the code.

To insert a module, click on Insert Menu and then select Module.

Insert a Blank Module
Insert a Blank Module

As we are going to automate MS Word from Excel hence, we need to provide the reference of MS Word Object library. To add the reference, click on Tools menu and then select References…

In reference window, select ‘Microsoft Word 16.0 Object Library’ from the available references and then click on Okay.

Add Microsoft Word 16.0 Object Library
Add Microsoft Word 16.0 Object Library

Once you are done with adding references then double click on Module1 to open the code window.

Start Coding
Start Coding

In Code window, just copy and paste the below code.

Now move to Excel Application and assign the macro on the button available on top of the table.

Assign Macro
Assign Macro

You can test this application with the data available in the table.

Download Excel and Word files used in this tutorial.

How To Create Automated Student Mark Sheet!! How To Create Automated Student Mark Sheet!! Reviewed by Time 2 Tech on June 07, 2020 Rating: 5

No comments:

Powered by Blogger.