Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

Changing Links takes a LONG time

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul Atkins - 21 Sep 2005 15:37 GMT
I wanted to write a macro to update the links to an Excel Spreadsheet to a
new Excel Spreadsheet, which I did do, and it works, but the macro takes an
incredibly long time (30-40 seconds) to execute the instruction:

                       aField.LinkFormat.SourceFullName = SourceFullName

As an aside, in changing the source, the fonts to fields annotated with \a
\f 5 \t   yield text in a new font from the original document, and the \*
MERGEFORMAT tag in the original document has been removed. The document is
only 21 pages long and about 200k in size.

I'm using Word 2003 (11.6359.6360) SP1

Any ideas?

Thanks

==================================================================

Public Sub SetLinks()
   Dim aField As Field
   Dim SourceFullNameName As String
   Dim LinkData() As String
   Dim NewData() As String
   Dim LinkCount As Integer
   Dim Index As Integer
   Dim FoundLink As Boolean

   ' First count the links to be processed
   LinkCount = 0
   For Each aField In ActiveDocument.Fields
       If aField.Type = wdFieldLink Then
           LinkCount = LinkCount + 1
       End If
   Next

   ' Redimension the LinkData array
   ReDim LinkData(1 To LinkCount)
   ReDim NewData(1 To LinkCount)

   ' Populate the LinkData array with LinkData
   Index = 0
   For Each aField In ActiveDocument.Fields
       If aField.Type = wdFieldLink Then
           Index = Index + 1
           LinkData(Index) = aField.OLEFormat.Label
       End If
   Next

   ' Now, update all the links to the new path
   SourceFullName = ActiveDocument.Path & "\" & _
       Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 3) & "xls"

   For Index = 1 To LinkCount
       FoundLink = False
       For Each aField In ActiveDocument.Fields
           If Not FoundLink Then
               If aField.Type = wdFieldLink Then
                   If aField.OLEFormat.Label = LinkData(Index) Then
                       aField.LinkFormat.SourceFullName = SourceFullName
'##################################
                       NewData(Index) = Format(Index, "##0. ") & _
                           aField.LinkFormat.SourceFullName & " " & _
                           aField.OLEFormat.Label
                       BreakHere = 1
                       FoundLink = True
                   End If
               End If
           End If
       Next aField
   Next Index
   BreakHere = 2
End Sub
macropod - 25 Sep 2005 00:12 GMT
Hi Paul,

Take a look at my Link updating utility at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=261488

Cheers

> I wanted to write a macro to update the links to an Excel Spreadsheet to a
> new Excel Spreadsheet, which I did do, and it works, but the macro takes an
[quoted text clipped - 69 lines]
>     BreakHere = 2
> End Sub

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.