SlideShare a Scribd company logo
1 of 3
Download to read offline
MS WORD
SOURCE CODE
Imports Microsoft.Office.Interop.Word
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim oWord As Microsoft.Office.Interop.Word.Application
Dim oDoc As Microsoft.Office.Interop.Word.Document
Dim oTable As Microsoft.Office.Interop.Word.Table
Dim oPara1 As Microsoft.Office.Interop.Word.Paragraph, oPara2 As
Microsoft.Office.Interop.Word.Paragraph
Dim oPara3 As Microsoft.Office.Interop.Word.Paragraph, oPara4 As
Microsoft.Office.Interop.Word.Paragraph
Dim oRng As Microsoft.Office.Interop.Word.Range
Dim oShape As Microsoft.Office.Interop.Word.InlineShape
Dim oChart As Object
Dim Pos As Double
oWord = CreateObject("Word.Application")
oWord.Visible = True
oDoc = oWord.Documents.Add
oPara1 = oDoc.Content.Paragraphs.Add
oPara1.Range.Text = "Heading 1"
oPara1.Range.Font.Bold = True
oPara1.Format.SpaceAfter = 24 '24 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter()
oPara2 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks("endofdoc").Range)
oPara2.Range.Text = "Heading 2"
oPara2.Format.SpaceAfter = 6
oPara2.Range.InsertParagraphAfter()
oPara3 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks("endofdoc").Range)
oPara3.Range.Text = "This is a sentence of normal text. Now here is a table:"
oPara3.Range.Font.Bold = False
oPara3.Format.SpaceAfter = 24
oPara3.Range.InsertParagraphAfter()
Dim r As Integer, c As Integer
oTable = oDoc.Tables.Add(oDoc.Bookmarks("endofdoc").Range, 3, 5)
oTable.Range.ParagraphFormat.SpaceAfter = 6
For r = 1 To 3
For c = 1 To 5
oTable.Cell(r, c).Range.Text = "r" & r & "c" & c
Next
Next
oTable.Rows(1).Range.Font.Bold = True
oTable.Rows(1).Range.Font.Italic = True
oPara4 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks("endofdoc").Range)
oPara4.Range.InsertParagraphBefore()
oPara4.Range.Text = "And here's another table:"
oPara4.Format.SpaceAfter = 24
oPara4.Range.InsertParagraphAfter()
oTable = oDoc.Tables.Add(oDoc.Bookmarks("endofdoc").Range, 5, 2)
oTable.Range.ParagraphFormat.SpaceAfter = 6
For r = 1 To 5
For c = 1 To 2
oTable.Cell(r, c).Range.Text = "r" & r & "c" & c
Next
Next
oTable.Columns(1).Width = oWord.InchesToPoints(2)
oTable.Columns(2).Width = oWord.InchesToPoints(3)
Pos = oWord.InchesToPoints(7)
oDoc.Bookmarks("endofdoc").Range.InsertParagraphAfter()
Do
oRng = oDoc.Bookmarks("endofdoc").Range
oRng.ParagraphFormat.SpaceAfter = 6
oRng.InsertAfter("A line of text")
oRng.InsertParagraphAfter()
Loop While Pos >=
oRng.Information(WdInformation.wdVerticalPositionRelativeToPage)
oRng.Collapse(WdCollapseDirection.wdCollapseEnd)
oRng.InsertBreak(WdBreakType.wdPageBreak)
oRng.Collapse(WdCollapseDirection.wdCollapseEnd)
oRng.InsertAfter("We're now on page 2. Here's my chart:")
oRng.InsertParagraphAfter()
oShape = oDoc.Bookmarks("endofdoc").Range.InlineShapes.AddOLEObject( _
ClassType:="MSGraph.Chart.8", FileName _
:="", LinkToFile:=False, DisplayAsIcon:=False)
oChart = oShape.OLEFormat.Object
oChart.charttype = 4 'xlLine = 4
oChart.Application.Update()
oChart.Application.Quit()
oShape.Width = oWord.InchesToPoints(6.25)
oShape.Height = oWord.InchesToPoints(3.57)
oRng = oDoc.Bookmarks("endofdoc").Range
oRng.InsertParagraphAfter()
oRng.InsertAfter("THE END.")
End Sub
End Class
OUTPUT:
MS Word source code to add paragraphs, tables, charts

More Related Content

What's hot

Microsoft Word - Mail Merge Tutorial
Microsoft Word - Mail Merge TutorialMicrosoft Word - Mail Merge Tutorial
Microsoft Word - Mail Merge TutorialBen-Murray
 
Mail merge made easy
Mail merge made easyMail merge made easy
Mail merge made easyRoel Palmaers
 
Mail merge define and process on mail merge and REVIEW TAB
Mail merge  define and process on mail merge and  REVIEW TABMail merge  define and process on mail merge and  REVIEW TAB
Mail merge define and process on mail merge and REVIEW TABAshish051992
 
Advance word-processing-skills final
Advance word-processing-skills finalAdvance word-processing-skills final
Advance word-processing-skills finalmelaniebitar
 
Mail merge - Get Complete Information !!
Mail merge - Get Complete Information !!Mail merge - Get Complete Information !!
Mail merge - Get Complete Information !!peterb8
 
Com6 recalling ms word
Com6 recalling ms wordCom6 recalling ms word
Com6 recalling ms wordJason Ruelo
 
Microsoft Office Specialist Word 2013
Microsoft Office Specialist Word 2013 Microsoft Office Specialist Word 2013
Microsoft Office Specialist Word 2013 Deborah Wagener
 
Inserting footnotes in Word and Google Docs
Inserting footnotes in Word and Google DocsInserting footnotes in Word and Google Docs
Inserting footnotes in Word and Google DocsBarb Jansen
 
OpenOffice.Org Writer Tutorial
OpenOffice.Org Writer TutorialOpenOffice.Org Writer Tutorial
OpenOffice.Org Writer Tutorialvargy
 
The opreting system and word processing
The opreting system and word processingThe opreting system and word processing
The opreting system and word processinghuyenanh123
 
Windows 10 mobile- will consumers move to the new platform
Windows 10 mobile- will consumers move to the new platformWindows 10 mobile- will consumers move to the new platform
Windows 10 mobile- will consumers move to the new platformEmilia Polesh
 
How To Copy A Newspaper Article & Save
How To Copy A Newspaper Article & SaveHow To Copy A Newspaper Article & Save
How To Copy A Newspaper Article & Savelakeverna
 

What's hot (20)

Microsoft Word - Mail Merge Tutorial
Microsoft Word - Mail Merge TutorialMicrosoft Word - Mail Merge Tutorial
Microsoft Word - Mail Merge Tutorial
 
Mail merge made easy
Mail merge made easyMail merge made easy
Mail merge made easy
 
Word ch06
Word ch06Word ch06
Word ch06
 
Mail merge define and process on mail merge and REVIEW TAB
Mail merge  define and process on mail merge and  REVIEW TABMail merge  define and process on mail merge and  REVIEW TAB
Mail merge define and process on mail merge and REVIEW TAB
 
Google Docs Documents
Google Docs DocumentsGoogle Docs Documents
Google Docs Documents
 
Advance word-processing-skills final
Advance word-processing-skills finalAdvance word-processing-skills final
Advance word-processing-skills final
 
Form 1 Term 2 Week 1.1
Form 1   Term 2   Week 1.1Form 1   Term 2   Week 1.1
Form 1 Term 2 Week 1.1
 
Mail merge - Get Complete Information !!
Mail merge - Get Complete Information !!Mail merge - Get Complete Information !!
Mail merge - Get Complete Information !!
 
Com6 recalling ms word
Com6 recalling ms wordCom6 recalling ms word
Com6 recalling ms word
 
Word processing
Word processingWord processing
Word processing
 
Mail merge
Mail mergeMail merge
Mail merge
 
Microsoft Office Specialist Word 2013
Microsoft Office Specialist Word 2013 Microsoft Office Specialist Word 2013
Microsoft Office Specialist Word 2013
 
Inserting footnotes in Word and Google Docs
Inserting footnotes in Word and Google DocsInserting footnotes in Word and Google Docs
Inserting footnotes in Word and Google Docs
 
What's New in Office 2016
What's New in Office 2016What's New in Office 2016
What's New in Office 2016
 
OpenOffice.Org Writer Tutorial
OpenOffice.Org Writer TutorialOpenOffice.Org Writer Tutorial
OpenOffice.Org Writer Tutorial
 
The opreting system and word processing
The opreting system and word processingThe opreting system and word processing
The opreting system and word processing
 
Ms word
Ms wordMs word
Ms word
 
Office 2010 Info
Office 2010 InfoOffice 2010 Info
Office 2010 Info
 
Windows 10 mobile- will consumers move to the new platform
Windows 10 mobile- will consumers move to the new platformWindows 10 mobile- will consumers move to the new platform
Windows 10 mobile- will consumers move to the new platform
 
How To Copy A Newspaper Article & Save
How To Copy A Newspaper Article & SaveHow To Copy A Newspaper Article & Save
How To Copy A Newspaper Article & Save
 

More from GOKUL SREE

UG_CS_DEPT_PRESENTATION.pptx
UG_CS_DEPT_PRESENTATION.pptxUG_CS_DEPT_PRESENTATION.pptx
UG_CS_DEPT_PRESENTATION.pptxGOKUL SREE
 
college quiz-1.pptx
college quiz-1.pptxcollege quiz-1.pptx
college quiz-1.pptxGOKUL SREE
 
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYSYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYGOKUL SREE
 
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYSYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYGOKUL SREE
 
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYSYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYGOKUL SREE
 
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYSYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYGOKUL SREE
 
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYSYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYGOKUL SREE
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITYDOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITYGOKUL SREE
 

More from GOKUL SREE (14)

UG_CS_DEPT_PRESENTATION.pptx
UG_CS_DEPT_PRESENTATION.pptxUG_CS_DEPT_PRESENTATION.pptx
UG_CS_DEPT_PRESENTATION.pptx
 
college quiz-1.pptx
college quiz-1.pptxcollege quiz-1.pptx
college quiz-1.pptx
 
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYSYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
 
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYSYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
 
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYSYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
 
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYSYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
 
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITYSYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
SYSTEM ADMINISTRATION AND MAINTENANCE NOTES PERIYAR UNIVERSITY
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITYDOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

MS Word source code to add paragraphs, tables, charts

  • 1. MS WORD SOURCE CODE Imports Microsoft.Office.Interop.Word Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oWord As Microsoft.Office.Interop.Word.Application Dim oDoc As Microsoft.Office.Interop.Word.Document Dim oTable As Microsoft.Office.Interop.Word.Table Dim oPara1 As Microsoft.Office.Interop.Word.Paragraph, oPara2 As Microsoft.Office.Interop.Word.Paragraph Dim oPara3 As Microsoft.Office.Interop.Word.Paragraph, oPara4 As Microsoft.Office.Interop.Word.Paragraph Dim oRng As Microsoft.Office.Interop.Word.Range Dim oShape As Microsoft.Office.Interop.Word.InlineShape Dim oChart As Object Dim Pos As Double oWord = CreateObject("Word.Application") oWord.Visible = True oDoc = oWord.Documents.Add oPara1 = oDoc.Content.Paragraphs.Add oPara1.Range.Text = "Heading 1" oPara1.Range.Font.Bold = True oPara1.Format.SpaceAfter = 24 '24 pt spacing after paragraph. oPara1.Range.InsertParagraphAfter() oPara2 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks("endofdoc").Range) oPara2.Range.Text = "Heading 2" oPara2.Format.SpaceAfter = 6 oPara2.Range.InsertParagraphAfter() oPara3 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks("endofdoc").Range) oPara3.Range.Text = "This is a sentence of normal text. Now here is a table:" oPara3.Range.Font.Bold = False oPara3.Format.SpaceAfter = 24 oPara3.Range.InsertParagraphAfter() Dim r As Integer, c As Integer oTable = oDoc.Tables.Add(oDoc.Bookmarks("endofdoc").Range, 3, 5) oTable.Range.ParagraphFormat.SpaceAfter = 6 For r = 1 To 3 For c = 1 To 5 oTable.Cell(r, c).Range.Text = "r" & r & "c" & c Next Next oTable.Rows(1).Range.Font.Bold = True oTable.Rows(1).Range.Font.Italic = True oPara4 = oDoc.Content.Paragraphs.Add(oDoc.Bookmarks("endofdoc").Range) oPara4.Range.InsertParagraphBefore() oPara4.Range.Text = "And here's another table:" oPara4.Format.SpaceAfter = 24 oPara4.Range.InsertParagraphAfter() oTable = oDoc.Tables.Add(oDoc.Bookmarks("endofdoc").Range, 5, 2) oTable.Range.ParagraphFormat.SpaceAfter = 6 For r = 1 To 5 For c = 1 To 2 oTable.Cell(r, c).Range.Text = "r" & r & "c" & c Next Next oTable.Columns(1).Width = oWord.InchesToPoints(2)
  • 2. oTable.Columns(2).Width = oWord.InchesToPoints(3) Pos = oWord.InchesToPoints(7) oDoc.Bookmarks("endofdoc").Range.InsertParagraphAfter() Do oRng = oDoc.Bookmarks("endofdoc").Range oRng.ParagraphFormat.SpaceAfter = 6 oRng.InsertAfter("A line of text") oRng.InsertParagraphAfter() Loop While Pos >= oRng.Information(WdInformation.wdVerticalPositionRelativeToPage) oRng.Collapse(WdCollapseDirection.wdCollapseEnd) oRng.InsertBreak(WdBreakType.wdPageBreak) oRng.Collapse(WdCollapseDirection.wdCollapseEnd) oRng.InsertAfter("We're now on page 2. Here's my chart:") oRng.InsertParagraphAfter() oShape = oDoc.Bookmarks("endofdoc").Range.InlineShapes.AddOLEObject( _ ClassType:="MSGraph.Chart.8", FileName _ :="", LinkToFile:=False, DisplayAsIcon:=False) oChart = oShape.OLEFormat.Object oChart.charttype = 4 'xlLine = 4 oChart.Application.Update() oChart.Application.Quit() oShape.Width = oWord.InchesToPoints(6.25) oShape.Height = oWord.InchesToPoints(3.57) oRng = oDoc.Bookmarks("endofdoc").Range oRng.InsertParagraphAfter() oRng.InsertAfter("THE END.") End Sub End Class OUTPUT: