J
JayM
I am creating a userform from a macro I have but I need further functionality
and extra buttons so an input box is no longer sufficient.
I have started with the basics but am having trouble unloading or hiding the
form once the OK button is clicked.
See code below. Any help appreciated.
Many thanks
JayM
Code:
Private Sub cmdOK_Click()
' Inserts User Texts
On Error GoTo errhandler
resultx = txtUserText
' InputBox("Please enter the name of the Text Segment you wish to use :",
"Enter Short Text")
If resultx = "" Then Exit Sub
resulty = Dir(varDriveZZword & "USERTEXT\" & resultx & ".DOC",
vbArchive + vbHidden + vbNormal + vbReadOnly + vbSystem)
If resulty = "" Then
MsgBox "Sorry, but '" & resultx & "' is NOT a valid Text Segment.
Please Try Again .....", vbCritical, resultx & " : NOT FOUND !"
Exit Sub
End If
Selection.InsertFile FileName:=varDriveZZword & "USERTEXT\" & resultx &
".DOC", Range:="", ConfirmConversions:= _
False, Link:=False, Attachment:=False
Exit Sub
errhandler:
MsgBox "Sorry, but '" & resultx & "' is NOT a valid Text Segment.
Please Try Again .....", vbCritical, resultx & " : NOT FOUND !"
frmUserText.Hide
End Sub
and extra buttons so an input box is no longer sufficient.
I have started with the basics but am having trouble unloading or hiding the
form once the OK button is clicked.
See code below. Any help appreciated.
Many thanks
JayM
Code:
Private Sub cmdOK_Click()
' Inserts User Texts
On Error GoTo errhandler
resultx = txtUserText
' InputBox("Please enter the name of the Text Segment you wish to use :",
"Enter Short Text")
If resultx = "" Then Exit Sub
resulty = Dir(varDriveZZword & "USERTEXT\" & resultx & ".DOC",
vbArchive + vbHidden + vbNormal + vbReadOnly + vbSystem)
If resulty = "" Then
MsgBox "Sorry, but '" & resultx & "' is NOT a valid Text Segment.
Please Try Again .....", vbCritical, resultx & " : NOT FOUND !"
Exit Sub
End If
Selection.InsertFile FileName:=varDriveZZword & "USERTEXT\" & resultx &
".DOC", Range:="", ConfirmConversions:= _
False, Link:=False, Attachment:=False
Exit Sub
errhandler:
MsgBox "Sorry, but '" & resultx & "' is NOT a valid Text Segment.
Please Try Again .....", vbCritical, resultx & " : NOT FOUND !"
frmUserText.Hide
End Sub