![]() |
#1
|
|||
|
|||
![]()
This is my UserForm:
Option Explicit Private Sub CommandButton1_Click() Dim PTFN As Range Set PTFN = ActiveDocument.Bookmarks("PTFN").Range PTFN.Text = Me.TextBox1.Value Dim PTLN As Range Set PTLN = ActiveDocument.Bookmarks("PTLN").Range PTLN.Text = Me.TextBox2.Value Dim DRFN As Range Set DRFN = ActiveDocument.Bookmarks("DRFN").Range DRFN.Text = Me.TextBox3.Value Dim DRLN As Range Set DRLN = ActiveDocument.Bookmarks("DRLN").Range DRLN.Text = Me.TextBox4.Value Me.Repaint UserForm1.Hide End Sub Private Sub UserForm_Click() End Sub I would like to also have a macro which will place "PTLN, PTFN" into save as box in the proper folder. I tried just putting the text as the first line of the document but only the text of PTLN will be accepted and the ", text of PTFN" will not appear. The document is a template.dotm which gets altered by several macros. The way I invoke save as is with F12. I tried the below code but am too inexperienced to understand what the errors mean and how to fix them. Sub SaveForm() Dim strPath As String Dim strName As String strPath = Environ("USERPROFILE") & "\Documents" ' strName = ActiveDocument.FormFields("FieldName").Result strName = ActiveDocument.Bookmarks("PTFN").Range If strName = "" Then MsgBox "Complete the 'fieldname' field!" ActiveDocument.Bookmarks("PTFN").Select Exit Sub End If With Dialogs(wdDialogFileSaveAs) .Name = strPath & strName .Show End With End Sub Thanks |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
filename field not displaying correct filename when that name starts with # | plrsmith | Word | 1 | 07-06-2018 03:10 AM |
![]() |
UnlimitedPower | Word VBA | 1 | 08-19-2016 12:22 AM |
Userform calls other userform, then populate worksheet | Lehoi | Excel Programming | 0 | 02-03-2016 02:58 PM |
VBA Code in a UserForm module to delete a Command Button which opens the userform | Simoninparis | Word VBA | 2 | 09-21-2014 03:50 AM |
![]() |
BoringDavid | Word VBA | 5 | 05-09-2014 09:08 AM |