Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-16-2023, 08:02 PM
Gravity Gravity is offline Hyperlinks bypassing Macro-Enabled Template Windows 10 Hyperlinks bypassing Macro-Enabled Template Office 2016
Novice
Hyperlinks bypassing Macro-Enabled Template
 
Join Date: Jul 2023
Posts: 2
Gravity is on a distinguished road
Default Hyperlinks bypassing Macro-Enabled Template

Hi,

I have some Word documents saved as Macro-Enabled Templates.



If users go to the folder and open the document they get a new copy as expected.

If I Hyperlink to the same documents when they click the hyperlink they open the original document and can over write it.

Is there a way to hyperlink and generate a copy and not open the original?


Thank you
Reply With Quote
  #2  
Old 07-16-2023, 08:43 PM
Charles Kenyon Charles Kenyon is offline Hyperlinks bypassing Macro-Enabled Template Windows 11 Hyperlinks bypassing Macro-Enabled Template Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,470
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

A hyperlink simply takes the user to the target. It is not the same as double-clicking on a template.


You can create a macro either by recording or writing it to create a new document based on the template. You can further use a MacroButton field to run the macro. It can be formatted as a hyperlink.

The first step in the macro, though, should be to collapse the selection because when a macro-button field is clicked on, the field is selected.

It will require a double-click to activate unless you set the option for a single-click.

Here is more on these fields:
Reply With Quote
  #3  
Old 07-16-2023, 09:34 PM
Gravity Gravity is offline Hyperlinks bypassing Macro-Enabled Template Windows 10 Hyperlinks bypassing Macro-Enabled Template Office 2016
Novice
Hyperlinks bypassing Macro-Enabled Template
 
Join Date: Jul 2023
Posts: 2
Gravity is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
A hyperlink simply takes the user to the target. It is not the same as double-clicking on a template.


You can create a macro either by recording or writing it to create a new document based on the template. You can further use a MacroButton field to run the macro. It can be formatted as a hyperlink.

The first step in the macro, though, should be to collapse the selection because when a macro-button field is clicked on, the field is selected.

It will require a double-click to activate unless you set the option for a single-click.

Here is more on these fields:

That is really annoying, thank you very much for your help.
Reply With Quote
  #4  
Old 07-17-2023, 11:37 AM
Charles Kenyon Charles Kenyon is offline Hyperlinks bypassing Macro-Enabled Template Windows 11 Hyperlinks bypassing Macro-Enabled Template Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,470
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Here are a macro that creates a new document based on a template and the function that helps set the path to find the template. (You can hard code the path instead, if you want. This one gets templates from my Workgroup Templates folder.)

Code:
Sub KenyonBill()
    '
    ' KenyonBill Macro
    ' Macro written 7/5/02 by Charles Kyle Kenyon
    ' "&chr(10)&"New letter based on Kenyon Letterhead form
    '   Calls WorkgroupPath Function (below)
    '
    Dim sTemplatesPath As String
    sTemplatesPath = WorkGroupPath & "Menus\Office Forms"

    Documents.Add Template:= _
                  sTemplatesPath & "Kenyon Bill Form.dotm" _
                  , NewTemplate:=False
End Sub
Code:
Function WorkGroupPath() As String
    '   Written by Charles Kenyon
    '   February 28, 2003
    '
    '   Used by templates menus to set location of templates.
    '   Returns workgroup tempates path with "" at the end.
    '
    '   This is needed because if the folder is a network drive rather
    '   than a folder, it will have the "" already. If it is a folder,
    '   it will not have the backslash. This function gives a string
    '   with the backslash in either case.
    '
    WorkGroupPath = Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath)
    If Right(WorkGroupPath, 1) <> "" Then
        WorkGroupPath = WorkGroupPath & ""
    End If
End Function
If running from a macrobutton field, include the following statement in the macro to create the document. Otherwise, the field remains selected.

Code:
Selection.Collapse
See also Making MacroButtonFields respond to a single click

You need to have the following command in an AutoMacro. This can be in your normal template or a document template. Without this, it takes a double-click to run the macro.
Code:
Options.ButtonFieldClicks = 1
Example for the normal template:
Code:
Sub AutoExec({)
    Options.ButtonFieldClicks = 1
End Sub
If you have a number of templates you want to create documents from, consider, instead of macrobutton fields, a custom Ribbon tab with the macros or adding them to your QAT.
Modifying the Quick Access Toolbar (QAT) in Microsoft Word
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlinks bypassing Macro-Enabled Template Add Tab Group Only If Owning Template is Enabled? KodosLives Word 4 02-06-2023 01:25 AM
Macro enabled Excel forms Ricco49 Excel Programming 2 11-01-2017 04:04 AM
Word 2010 Macro Enabled Template with Content Controls keen1598 Word VBA 7 01-29-2014 03:17 PM
Hyperlinks bypassing Macro-Enabled Template Saving as ( PowerPoint Macro-Enabled Slide Show )?? delete123 PowerPoint 2 04-10-2013 05:38 AM
Hyperlinks bypassing Macro-Enabled Template Macro-enabled Template ReviTULize Word VBA 4 02-01-2013 01:46 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:34 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft