![]() |
|
#1
|
|||
|
|||
|
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
Best Regards |
|
#2
|
||||
|
||||
|
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] |
|
#3
|
|||
|
|||
|
Quote:
What do you mean by that ? Can you put a didactic link please ? Best Regards |
|
#4
|
||||
|
||||
|
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 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] |
|
#5
|
|||
|
|||
|
Thanks a lot.
Now is clear for me. Best Regards |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Word 2010 form template not working
|
steambc | Word | 7 | 08-28-2013 09:05 AM |
Normal Template in Word 2010
|
Castor | Word | 1 | 03-17-2013 04:27 PM |
Sub or Function not defined error - GetParaIndex Word 2010
|
jec1 | Word VBA | 1 | 05-24-2012 11:58 PM |
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 |