DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Add a word 2010 function to template  (Read 4,785 times)

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Add a word 2010 function to template
« on: February 20, 2014, 06:59 PM »
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: (vb)
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....
« Last Edit: February 20, 2014, 07:45 PM by Contro »

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,840
    • Coding Snacks
Re: Add a word 2010 function to template
« Reply #1 on: February 20, 2014, 11:56 PM »
pretty sure you should copy it into the normal.dotm...
Alcohol is photoshop, bottled
Askhole - someone who ask for advice, then ignores it
"Look wise, say nothing, and grunt. Speech was given to conceal thought" - Sir William Osler

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: Add a word 2010 function to template
« Reply #2 on: February 21, 2014, 01:58 AM »
pretty sure you should copy it into the normal.dotm...

But How ?. I have a headache trying to see how to save the script/macro/VBA file . :-[

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,840
    • Coding Snacks
Re: Add a word 2010 function to template
« Reply #3 on: February 21, 2014, 02:22 AM »
open the VBA editor (SHIFT+F11) and copy to the NORMAL document.

if there's no module associated with NORMAL you can copy the module from the existing file, otherwise just copy and paste the code (then SAVE SAVE SAVE)
Alcohol is photoshop, bottled
Askhole - someone who ask for advice, then ignores it
"Look wise, say nothing, and grunt. Speech was given to conceal thought" - Sir William Osler

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: Add a word 2010 function to template
« Reply #4 on: February 21, 2014, 10:48 AM »
open the VBA editor (SHIFT+F11) and copy to the NORMAL document.

if there's no module associated with NORMAL you can copy the module from the existing file, otherwise just copy and paste the code (then SAVE SAVE SAVE)

Copy how ?. A step by step ? I am lost.
:-[

Original address: https://www.donationcoder.com/forum/index.php?topic=37314.0