• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

Create New Word Document


I am doing a small simple project where I am creating a Word Document (i'll call it Doc1) which will hold all the VBA/Macro code to create a new Word Document (i'll call it Doc2) partly based on information they have typed into User Form within Doc1; for example the User Form in Doc 1 will ask the user for a Document title. The user will enter the title of the document and click a create button which will create a new Word Document (Doc2) and add into it the title the user has entered into the User Form from Doc 1.

This appears very simple. However can anyone please point me in the right direction of the following; I am ok with creating and capturing all the information in the text fields on the User Form (Doc1) its just the creation of the document that I need help with.

1. How can I create a new Word Document and name it Doc2.docx and save it to my desktop?
2. Once the document has been created; add the title as entered into my User Form from Doc1?

Thanks in advance,


  • 2
2 Solutions
Note that VBA projects are usually in templates, rather than documents.

To name a document, you must save it.

Sub NewDoc()
    Dim Doc As Document
    Set Doc = Documents.Add '(TemplatePath) if not Normal
    Doc.SaveAs "C:\MyFolder\" & TextBox1.Text & ".Docx"
End Sub

Open in new window

- i would assume you have a module and a form called UserForm1, a textbox and a command button to click on for creation of a new document:

-- this is on Modules. call to display UserForm1 :
Sub NewDoc()
End Sub

Open in new window

-- this is on UserForm1 which contain a textbox called Textbox1 and command button called CommandButton1.:

Private Sub CommandButton1_Click()
  Set objWord = CreateObject("Word.Application")
  objWord.Caption = "This is Word Caption"
  objWord.Visible = True

  Set objDoc = objWord.Documents.Add()
  Set objSelection = objWord.Selection

  objSelection.Font.Name = "Arial"
  objSelection.Font.Size = "18"
   'this will display the title on the document
  objSelection.TypeText "Title: " & UserForm1.TextBox1.Text   

  'change the <profilename> below to your windows login profile id. 
  'test to open the desktop folder by typing the whole folder name on windows explorer 
  objDoc.SaveAs ("C:\Documents and Settings\profilename\Desktop\doc2.docx") 

End Sub

Open in new window

Yes, the use of the word 'Title' is a little ambiguous in Word.

There is a built-in Title property. It could mean the first text, probably with a Heading 1 style, or it could be the stem of the document's file name (or even all three).
gisvpnAuthor Commented:
Perfect thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now