Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 18095

I am trying to create filename using the UserForm text box with VBA in Word

$
0
0

I am working in Word 2007. I have created a Macro-Enabled Template that I am trying to automate the .SaveAs based on the input of a text box from a UserForm. How do I dim and set the input text to use in the filename?

Sub AutoNew()frmCustName.ShowDim Cust As StringCust = txtInputActiveDocument.SaveAs FileName:="MyPath" & Cust & ".docm"End Sub

Here is my UserForm Macro.
My UserForm = "frmCustName"
My TextBox = "txtInput"
My CommandButton = "cmdName"

Private Sub cmdName_Click()Dim BK As StringBK = txtInputDim NameBK1 As RangeSet NameBK1 = ActiveDocument.Bookmarks("CName1").RangeNameBK1.Text = BKDim NameBK2 As RangeSet NameBK2 = ActiveDocument.Bookmarks("CName2").RangeNameBK2.Text = BKfrmCustName.HideEnd Sub

I'm a newbie and my brain is completely fried at this point.


Viewing all articles
Browse latest Browse all 18095

Trending Articles