T
Taylor
I have found several past posts on locking links in VBA. (Cribbed code
is included at the footer of the message.)
I would like to discover the programmatic equivalent of the manual
method of locking links: Edit--->Links (Opens dialogue); Select all
links, check 'Locked' box; click OK.
Problems with my current VBA method:
a) the original linked source file needs to be present for my code to
even work. (Not the case with locking links manually.)
Running code sans source file returns: "Run-time error '6083' Objects
in this document contain links to files that cannot be found. The
linked information will not be updated," leading to the next issue...
b) With the code, Word first updates the links before setting them to
Locked. Not desirable, timewise (manual locks instantaneously, vba
takes 1.5 min+) & the updates are likely irrelevant to the current
doc.
c) The other thing that is so darn snazzy about the manual method is
that it doesn't care if it is a field, shape, inline shape; it just
locks the bugger. In code, I need separate processes to deal with each
type of link (Probably unavoidable).
Any help is greatly appreciated. Thanks!
Taylor
P.S. I had high hopes of running the macro recorder during the above
manual process; alas, it registers nothing (results in blank macro
code).
Here's the code:
Dim i As Long
For i = 1 To ActiveDocument.Shapes.Count
If Not ActiveDocument.Shapes(i).LinkFormat Is Nothing Then
If Not ActiveDocument.Shapes(i).LinkFormat.Locked Then
ActiveDocument.Shapes(i).LinkFormat.Locked = True
End If
End If
Next i
is included at the footer of the message.)
I would like to discover the programmatic equivalent of the manual
method of locking links: Edit--->Links (Opens dialogue); Select all
links, check 'Locked' box; click OK.
Problems with my current VBA method:
a) the original linked source file needs to be present for my code to
even work. (Not the case with locking links manually.)
Running code sans source file returns: "Run-time error '6083' Objects
in this document contain links to files that cannot be found. The
linked information will not be updated," leading to the next issue...
b) With the code, Word first updates the links before setting them to
Locked. Not desirable, timewise (manual locks instantaneously, vba
takes 1.5 min+) & the updates are likely irrelevant to the current
doc.
c) The other thing that is so darn snazzy about the manual method is
that it doesn't care if it is a field, shape, inline shape; it just
locks the bugger. In code, I need separate processes to deal with each
type of link (Probably unavoidable).
Any help is greatly appreciated. Thanks!
Taylor
P.S. I had high hopes of running the macro recorder during the above
manual process; alas, it registers nothing (results in blank macro
code).
Here's the code:
Dim i As Long
For i = 1 To ActiveDocument.Shapes.Count
If Not ActiveDocument.Shapes(i).LinkFormat Is Nothing Then
If Not ActiveDocument.Shapes(i).LinkFormat.Locked Then
ActiveDocument.Shapes(i).LinkFormat.Locked = True
End If
End If
Next i