MS Word VBA Interview Questions and Answers with Examples
MS Word VBA Interview Questions and Answers explained with Example macros. Here are the list of most frequently asked basic MS Word VBA interview questions. All the questions are answered with simple examples. These questions will help you to answer basic questions to deal with MS Word VBA development.
Here is the following VBA macro to create a new Word document.
‘Create New Word Document
‘Create New Word Document
Sub Create_Documnent() Documents.Add End Sub
Here is the following VBA procedure to create a word document from the existing word documnet
'Create new word document based on existing word document Sub Create_Doc_ReadOnly() Documents.Add Template:="D:/Test.doc", NewTemplate:=True End Sub
Here is the following VBA procedure to create a word document as a read only document.
'Open a Existing Word Document (Read Only Document) Sub Open_Doc_ReadOnly() Documents.Open FileName:="D:/Test.doc", ReadOnly:=True End Sub
Here is the following VBA code to save a word document.
'Save Word Document if already not saved Sub Save_Documnent() If ActiveDocument.Saved = False Then ActiveDocument.Save End If End Sub
Here is the following VBA procedure to SaveAs a word document.
'SaveAs Word Document if already not saved Sub SaveAs_Documnent() ActiveDocument.SaveAs ("d:/Test.doc") End Sub
Here is the following VBA procedure to create a word document as a read only document.
'Save and Close Document Sub Save_Close_Document() Documents.Close SaveChanges:=wdSaveChanges Application.Quit SaveChanges:=wdSaveChanges End Sub
Here is the following VBA procedure to create a word document as a read only document.
'Close document without save Sub DoNotSave_Close_Document() Documents.Close SaveChanges:=wdDoNotSaveChanges Application.Quit SaveChanges:=wdDoNotSaveChanges End Sub
Here is the following VBA code. It takes cursor to the start of the document.
code:
code:
Selection.HomeKey Unit:=wdStory
Here is the following VBA code. It takes cursor to the end of the document.
code:
code:
Selection.EndKey Unit:=wdStory
Here is the following VBA code. It takes cursor to the start of the line.
code:
code:
Selection.HomeKey Unit:= wdLine
Here is the following VBA code. It takes cursor to the end of the line.
code:
code:
Selection.EndKey Unit:= wdLine
Here is the following VBA code. It selects entire word document.
code:
code:
Selection.WholeStory
Here is the following VBA snippet. It selects entire word document.
'Select the current line in a word document Sub Select_Line_Document() Selection.HomeKey Unit:=wdLine Selection.EndKey Unit:=wdLine, Extend:=wdExtend End Sub
Here is the following VBA macro. It changes the font size of third paragraph.
'Change font size of 3rd paragraph Sub Paragraph_Font_Size_Document() ActiveDocument.Paragraphs(3).Range.Font.Size = 10 End Sub
More VBA Interview Questions & Answers:
Here is the link for more VBA Interview Questions and Answers. These are explained for examples.
100+ VBA Interview Questions