简体   繁体   中英

Changing a word document title with Textbox values

Im currently making a VBA userform with multiple textboxes. My goal is to make a macro enabled word template that pops up a userform on startup, containing multiple textboxes where the user can input values.

I was looking for a way to change the default save title of my word document. I wanted to pass input values from textboxes into the title so that it would look something like this:

"Textbox1.Value_Textbox2.Value_Combobox1.Value_Textbox3.Value_....." (Space for the user to personalize the document name)

The underscore seperation is very important.

I tried setting it with

   'WORKS'
With Dialogs(wdDialogFileSummaryInfo)
    .Title = TextBox7.Value
    .Execute
End With

With the aim to combine all those textbox values into textbox 7 but i just cant get it to work. Is there any other way to fix this issue?

you may try this:

With Me
    .TextBox7 = Join(Array(.TextBox1.Text, .TextBox2.Text, .ComboBox1.Value, .TextBox3.Text), "_") '<--| list your controls 'name.property' in the desired order
End With

With Dialogs(wdDialogFileSummaryInfo)
    .Title = Me.TextBox7.Text
    .Execute
End With

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM