LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (July 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 26 Jul 2007 03:57:46 -0000
Reply-To:     Stanley Wei <medpower@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Stanley Wei <medpower@GMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: How could I add multi-hyperlinks automatically in a word
Comments: To: sas-l@uga.edu
In-Reply-To:  <8AD8F86B3312F24CB432CEDDA71889F203EF7A64@ex06.GHCMASTER.GHC.ORG>
Content-Type: text/plain; charset="us-ascii"

Thanks Roy,

I wrote the following word VBA code in. I have stored the items to be find and hyperlink address in an access database, the database and table name are both called TOC (fileds include TLFNO and LINKADDRESS), could anyone help me find the problem of the following codes? it just work for the first found item, I need to operate for all of items met with the requirements, thanks!

Stanley

Private Sub CommandButton3_Click() Dim CNN, RS1 Dim strSQL1$, strFind$ Dim myRange As Range

Set CNN = CreateObject("Adodb.Connection") Set RS1 = CreateObject("Adodb.Recordset") strPath = ThisDocument.Path & "\TOC.mdb" CNN.Provider = "Microsoft.Jet.OLEDB.4.0" CNN.Open "Data Source =" & strPath & ";Jet OLEDB:Database Password=" & ""

strSQL1 = "select * from TOC" RS1.Open strSQL1, CNN, 1, 3

Application.ScreenUpdating = False For i = 1 To RS1.RecordCount strFind = RS1.Fields("TLFNO") Set myRange = ActiveDocument.Content With myRange.Find .ClearFormatting .Format = True .Font.Color = wdColorBlue .Text = RS1.Fields("TLFNO") If .Execute(findtext:=strFind) = True Then myRange.Select ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:=RS1.Fields("LinkAddress"), _ SubAddress:="", ScreenTip:="", TextToDisplay:=RS1.Fields("TLFNO") End If End With RS1.movenext Next

Application.ScreenUpdating = True RS1.Close End Sub


Back to: Top of message | Previous page | Main SAS-L page