Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-24-2020, 02:01 PM
savvy savvy is offline userForm input for filename Windows 10 userForm input for filename Office 2016
Novice
userForm input for filename
 
Join Date: Aug 2020
Location: Toronto
Posts: 23
savvy is on a distinguished road
Default userForm input for filename

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
Reply With Quote
 



Similar Threads
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
userForm input for filename Filename 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
userForm input for filename Is it possible to take an input from a UserForm in one document to a UserForm in a do BoringDavid Word VBA 5 05-09-2014 09:08 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft