Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-20-2014, 02:15 PM
Esgrimidor Esgrimidor is offline Add a word 2010 function to template Windows XP Add a word 2010 function to template Office XP
Advanced Beginner
Add a word 2010 function to template
 
Join Date: Jun 2009
Posts: 35
Esgrimidor is on a distinguished road
Default Add a word 2010 function to template

How can I add this word function (macro) to the template exactly. I try with no results. I get functioning, but not to save to template for not copy/paste everytime I want to execute the function in a document to extract the hiperlinks.....


For word 2010


This is the code :
Code:
    Function doHL()
     
    Dim nd As Document
    Dim a As Document
    Dim h As Hyperlink
    Dim r As Range
    Application.ScreenUpdating = False
    Set a = ActiveDocument
    Set nd = Documents.Add
    For Each h In a.Hyperlinks
    Set r = nd.Range
    r.Collapse
    r.InsertParagraph
    r.InsertAfter (h.Address)
    Next
    nd.Activate
    Application.ScreenUpdating = True
    Application.ScreenRefresh
    End Function
Save the function to the normal.dotm or corresponding to have for ever available....

Best Regards
Reply With Quote
  #2  
Old 02-21-2014, 02:06 PM
macropod's Avatar
macropod macropod is offline Add a word 2010 function to template Windows 7 32bit Add a word 2010 function to template Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Since it's implemented as a Function, instead of as a Sub, you would need a Sub to call it, regardless of where it's stored.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 02-22-2014, 06:35 PM
Esgrimidor Esgrimidor is offline Add a word 2010 function to template Windows XP Add a word 2010 function to template Office XP
Advanced Beginner
Add a word 2010 function to template
 
Join Date: Jun 2009
Posts: 35
Esgrimidor is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Since it's implemented as a Function, instead of as a Sub, you would need a Sub to call it, regardless of where it's stored.

What do you mean by that ? Can you put a didactic link please ?

Best Regards
Reply With Quote
  #4  
Old 02-22-2014, 08:09 PM
macropod's Avatar
macropod macropod is offline Add a word 2010 function to template Windows 7 32bit Add a word 2010 function to template Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Functions cannot be run on their own; they need something else (e.g. a Sub) to run them. For example, you might use:
Code:
Sub Extract_Hyperlinks
doHL
End Sub
Alternatively, if you want to be able to run your code directly, change:
Function doHL()
to:
Sub doHL()
and change:
End Function
to:
End Sub
(this latter change occurs automatically if you do the first one).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 02-23-2014, 06:59 AM
Esgrimidor Esgrimidor is offline Add a word 2010 function to template Windows XP Add a word 2010 function to template Office XP
Advanced Beginner
Add a word 2010 function to template
 
Join Date: Jun 2009
Posts: 35
Esgrimidor is on a distinguished road
Default

Thanks a lot.
Now is clear for me.
Best Regards
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Add a word 2010 function to template Word 2010 form template not working steambc Word 7 08-28-2013 09:05 AM
Add a word 2010 function to template Normal Template in Word 2010 Castor Word 1 03-17-2013 04:27 PM
Add a word 2010 function to template Sub or Function not defined error - GetParaIndex Word 2010 jec1 Word VBA 1 05-24-2012 11:58 PM
Add a word 2010 function to template Word 2010 Startup with template screes mark.osborne Word 3 08-19-2011 04:19 AM
ActiveX controls inserted on a template do not function well ged Word 0 10-21-2010 04:53 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:25 AM.


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