Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-07-2019, 05:54 AM
taryn taryn is offline Copying text from a cell in the footer and pasting it into a hyperlink address Windows 10 Copying text from a cell in the footer and pasting it into a hyperlink address Office 2016
Novice
Copying text from a cell in the footer and pasting it into a hyperlink address
 
Join Date: Jan 2015
Location: Gibraltar
Posts: 21
taryn is on a distinguished road
Default Copying text from a cell in the footer and pasting it into a hyperlink address

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+)&currency=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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying text from a cell in the footer and pasting it into a hyperlink address Copying and Pasting from Other Programs Results in Italicized Text 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
Copying text from a cell in the footer and pasting it into a hyperlink address Maintain formatting while copying text from word, and pasting into a webpage. kdogg121 Word 1 07-07-2009 02:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:56 AM.


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