Automatically naming documents after creating them?

I'm looking to make a macro that automatically creates a new document, then names it based on the values from a textbox. It would be called upon submission of the textbox. Ideally, it would name the doc "TB1.Value, TB2.Value, TB3.Value" obviously filling the actual values for all of those? Is there a way to do this? Currently I just use the following-

Dim newDoc As Document

Set newDoc = CreateDocument

not sure if there's a way to add naming to this. Any help would be great! Thanks

No Data
  • If you were having the macro create and save the file, then the naming would be part of the "SaveAs" operation.

    If you want to create a new document without saving it, but want to set what the Title is for the document, then you could do that by using CreateDocumentEx, and setting the name in the associated StructCreateOptions.

    Sub new_doc_named()
    Dim opt As New StructCreateOptions
        opt.Name = "foo"
        CreateDocumentEx opt
    End Sub