Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Insert Hyperlink in Locked Form
I have a locked form that I want individual users to insert a hyperlink to a
specific Visio file. Each link in each form will be unique, created by the user. With the form being locked, it seems there is no way to insert the hyperlink. I've tried inserting a Text Form Field, but once the form is locked the hyperlink option is disabled. |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Insert Hyperlink in Locked Form
I think this can be done, but the method is going to be a bit bizarre.
There's a method -- itself a convoluted workaround -- at http://www.word.mvps.org/FAQs/TblsFl...nksInForms.htm for creating a Hyperlink field nested inside a MacroButton field in a protected form. That creates a static (non-editable) hyperlink. Starting from that idea, what you would need is another macro -- probably one that displays a popup dialog -- that lets the user choose the path to the Visio file. Then the macro would (a) unprotect the form, (b) build the MacroButton/Hyperlink field construct (for which the macro needs to know where to put the field), and (c) reprotects the form. Where in the form does the link go -- at a bookmark, in a particular cell of a particular table, or something else? Does your form need to provide for more than one Visio file link per copy of the form? -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Mon, 15 Jan 2007 14:19:01 -0800, Critter wrote: I have a locked form that I want individual users to insert a hyperlink to a specific Visio file. Each link in each form will be unique, created by the user. With the form being locked, it seems there is no way to insert the hyperlink. I've tried inserting a Text Form Field, but once the form is locked the hyperlink option is disabled. |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Insert Hyperlink in Locked Form
Jay,
The link will go in a particular cell of a table in the form and will only be linked to one Visio file. "Jay Freedman" wrote: I think this can be done, but the method is going to be a bit bizarre. There's a method -- itself a convoluted workaround -- at http://www.word.mvps.org/FAQs/TblsFl...nksInForms.htm for creating a Hyperlink field nested inside a MacroButton field in a protected form. That creates a static (non-editable) hyperlink. Starting from that idea, what you would need is another macro -- probably one that displays a popup dialog -- that lets the user choose the path to the Visio file. Then the macro would (a) unprotect the form, (b) build the MacroButton/Hyperlink field construct (for which the macro needs to know where to put the field), and (c) reprotects the form. Where in the form does the link go -- at a bookmark, in a particular cell of a particular table, or something else? Does your form need to provide for more than one Visio file link per copy of the form? -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Mon, 15 Jan 2007 14:19:01 -0800, Critter wrote: I have a locked form that I want individual users to insert a hyperlink to a specific Visio file. Each link in each form will be unique, created by the user. With the form being locked, it seems there is no way to insert the hyperlink. I've tried inserting a Text Form Field, but once the form is locked the hyperlink option is disabled. |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Insert Hyperlink in Locked Form
Sorry to leave you hanging for a few days.
In your template, in the cell where you want the hyperlink to go, insert a MacroButton field with this code: MACROBUTTON generateHyperlink Click here The "Click here" part can be replaced with whatever text (or even a picture) you want to display to tell the user to click it. Insert all of the following code in a module in the template (http://www.gmayor.com/installing_macro.htm has instructions if you need them). Fill in the password for the form, if there is one. Protect and save the template, then create a new document based on it and click the MacroButton -- it will be active even though it isn't in a form field or unprotected area. Sub generateHyperlink() Dim oRg As Range Dim dlg As FileDialog Dim filePath As String, fileName As String Dim PW As String ' IMPORTANT: If the form is password protected, ' enter the password here PW = "" ' let the user choose the Visio file Set dlg = Application.FileDialog(msoFileDialogFilePicker) With dlg .AllowMultiSelect = False .Filters.Clear .Filters.Add "All Visio files", "*.vs*; *.v?x", 1 If .Show = -1 Then ' save the selected file path\name filePath = .SelectedItems(1) ' extract just the filename for display fileName = WordBasic.FileNameInfo(filePath, 3) ' the hyperlink syntax requires ' backslashes to be doubled filePath = Replace(filePath, "\", "\\") Set dlg = Nothing Else ' user canceled the dialog Set dlg = Nothing Exit Sub End If End With ' temporarily turn off form protection With ActiveDocument If .ProtectionType wdNoProtection Then .Unprotect Password:=PW End If End With ' hide what we're doing Application.ScreenUpdating = False ' display field codes ActiveWindow.View.ShowFieldCodes = True With Selection ' create the hyperlink, replacing the ' original Macrobutton field .Text = filePath .Hyperlinks.Add Anchor:=Selection.Range, _ Address:=filePath, TextToDisplay:=fileName .MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend ' create the new Macrobutton field, enclosing the hyperlink .Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _ PreserveFormatting:=False .InsertAfter "MacroButton ""FollowLink""" ' collapse the field and update it ActiveWindow.View.ShowFieldCodes = False .MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend .Fields.Update End With ' restore the screen Application.ScreenUpdating = True ' reprotect the document ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _ NoReset:=True, Password:=PW End Sub Sub FollowLink() On Error Resume Next Selection.Hyperlinks(1).Follow End Sub Sub AutoNew() Options.ButtonFieldClicks = 1 End Sub Sub AutoOpen() Options.ButtonFieldClicks = 1 End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Tue, 16 Jan 2007 08:01:01 -0800, Critter wrote: Jay, The link will go in a particular cell of a table in the form and will only be linked to one Visio file. "Jay Freedman" wrote: I think this can be done, but the method is going to be a bit bizarre. There's a method -- itself a convoluted workaround -- at http://www.word.mvps.org/FAQs/TblsFl...nksInForms.htm for creating a Hyperlink field nested inside a MacroButton field in a protected form. That creates a static (non-editable) hyperlink. Starting from that idea, what you would need is another macro -- probably one that displays a popup dialog -- that lets the user choose the path to the Visio file. Then the macro would (a) unprotect the form, (b) build the MacroButton/Hyperlink field construct (for which the macro needs to know where to put the field), and (c) reprotects the form. Where in the form does the link go -- at a bookmark, in a particular cell of a particular table, or something else? Does your form need to provide for more than one Visio file link per copy of the form? -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Mon, 15 Jan 2007 14:19:01 -0800, Critter wrote: I have a locked form that I want individual users to insert a hyperlink to a specific Visio file. Each link in each form will be unique, created by the user. With the form being locked, it seems there is no way to insert the hyperlink. I've tried inserting a Text Form Field, but once the form is locked the hyperlink option is disabled. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
hyperlink to template is opened instead of new document | Microsoft Word Help | |||
How do I insert cross-reference in form | Microsoft Word Help | |||
Merging data into a locked form? | Page Layout | |||
Alternate Text with HyperLink in locked form? | Microsoft Word Help | |||
how do i insert a hyperlink into a form? | Microsoft Word Help |