Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Critter Critter is offline
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Critter Critter is offline
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
hyperlink to template is opened instead of new document HyperNewDoc Microsoft Word Help 9 December 20th 13 03:34 PM
How do I insert cross-reference in form Carol Microsoft Word Help 9 July 19th 06 09:40 PM
Merging data into a locked form? Phillip F. Bressoud Page Layout 1 February 22nd 06 03:33 PM
Alternate Text with HyperLink in locked form? Todd Burch Microsoft Word Help 5 December 19th 05 01:11 PM
how do i insert a hyperlink into a form? Kay Microsoft Word Help 1 January 24th 05 12:59 PM


All times are GMT +1. The time now is 02:12 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"