J
JayM
i have a folder which is referenced in a global constant (varUSERTEXT)
This following code works fine if the text entered into the Inputbox is an
actual word document. If the text entered is for a shortcut to then it
errors. What I wanted to do was tidy the folder up for each department so
they could browse to the folder if needs be (using a userform rather than an
input box) but if they know the filename just enter it without having any
other input. hence I would have a shortcut reference in varUSERTEXT
Sub InsertText()
' Inserts User Texts
On Error GoTo errhandler
resultx = InputBox("Please enter the name of the Text Segment you wish
to use :", "Enter Short Text")
If resultx = "" Then Exit Sub
resulty = Dir(varUSERTEXT & 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:=varUSERTEXT & 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 !"
End Sub
This following code works fine if the text entered into the Inputbox is an
actual word document. If the text entered is for a shortcut to then it
errors. What I wanted to do was tidy the folder up for each department so
they could browse to the folder if needs be (using a userform rather than an
input box) but if they know the filename just enter it without having any
other input. hence I would have a shortcut reference in varUSERTEXT
Sub InsertText()
' Inserts User Texts
On Error GoTo errhandler
resultx = InputBox("Please enter the name of the Text Segment you wish
to use :", "Enter Short Text")
If resultx = "" Then Exit Sub
resulty = Dir(varUSERTEXT & 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:=varUSERTEXT & 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 !"
End Sub