![]() |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
Hello
I am trying to create a macro that will run automatically when a word document is opened and will do the following: 1) Copy the six digits contained in a table located in the footer of the 1st page of the document; 2) Paste the above six digits into the address of a hyperlink also located in the table in the footer of the 1st page of the document (different cell) replacing some of the text already in the address. I am completely new to word macros and the Record Macro button only does what I ask partly: ================================================== Sub Macro3() ' ' Macro3 Macro ' ' If ActiveWindow.View.SplitSpecial <> wdPaneNone Then ActiveWindow.Panes(2).Close End If If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _ ActivePane.View.Type = wdOutlineView Then ActiveWindow.ActivePane.View.Type = wdPrintView End If ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter Selection.Range.Copy ChangeFileOpenDirectory _ "C:\Users\taryn.avellano\Documents\ViewPoint.gibsq l01.VPMain" Selection.Range.Hyperlinks(1).Range.Fields(1).Resu lt.Select Selection.Range.Hyperlinks(1).Delete ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _ "https://secure.worldpay.com/wcc/purchase?instId=1033965&cartId=20150013&amount=(+D T.EURO+)¤cy=GBP&desc=WorldPay+Test&testMode= 100" _ , SubAddress:="" Selection.Collapse Direction:=wdCollapseEnd End Sub ================================================== The above macro does copy the six digits (i.e. 20150013) and pastes it into the hyperlink address. However, it has the following limitations, which makes it unusable for me, as I need it to require no action on behalf of the user opening the document: 1) It only works when I run it after having highlighted the hyperlink object. I need it to run automatically when the word document is opened; 2) It always pastes the same six digits (i.e. 20150013) into the hyperlink address, instead of copying the six digits contained in the table located in the footer of the 1st page of the document, which changes with each document. Any help would be greatly appreciated. Kind regards. Taryn |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
CrossReach | Word | 3 | 02-20-2017 02:08 PM |
copying and pasting text format | paik1002 | Excel | 2 | 10-07-2016 02:34 AM |
Copying and pasting from Amazon sales to MS Word the text is garbled. | voyagerone | Word | 6 | 09-08-2015 04:18 PM |
Pasting text from Excel cell into word without creating a table, and keeping the in-cell formatting | hanvyj | Excel Programming | 0 | 08-28-2015 01:15 AM |
![]() |
kdogg121 | Word | 1 | 07-07-2009 02:50 AM |