Prev: word and reports
Next: How to 1. Jump to a specific page (in a massive document) based on a search then 2. Copy and paste an string of characters a few lines above it.
From: JayM on 23 Mar 2010 06:08 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
From: Doug Robbins - Word MVP on 23 Mar 2010 17:32 For what you have shown, an InputBox should be sufficient. However See thefollowing page of Greg Maxey's website : http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "JayM" <JayM(a)discussions.microsoft.com> wrote in message news:7F460292-FCB4-4217-B2D1-C7D37BCB3399(a)microsoft.com... > 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 >
From: JayM on 24 Mar 2010 08:25
Hi Doug. Thanks for that. I had actually worked out what I was doing wrong. With regard to the Input box that is what we are currently using but I now want to be able to add some extra buttons to go to different locations so the user can select the text rather than remembering it's name. However, it would be nice to have the choice so my thinking was to put some sub folders in where the user could browse to but in the USERTEXT folder have a shortcut to the sub folders so that the filename could be typed in. Unfortunately this just results in the error message saying the file doesn't exist. Do you know if there is a way around this? JayM "Doug Robbins - Word MVP" wrote: > For what you have shown, an InputBox should be sufficient. > > However See thefollowing page of Greg Maxey's website : > > http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm > > > -- > Hope this helps. > > Please reply to the newsgroup unless you wish to avail yourself of my > services on a paid consulting basis. > > Doug Robbins - Word MVP, originally posted via msnews.microsoft.com > > "JayM" <JayM(a)discussions.microsoft.com> wrote in message > news:7F460292-FCB4-4217-B2D1-C7D37BCB3399(a)microsoft.com... > > 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 > > |