Word Macro won't record

G

g

Word 97, Windows XP Home

I use the macro recorder to automate various tasks. I don't hand edit
the macros, except to remove a line here and there. I made a macro to
insert a Word file that has many links from an Excel sheet. The Word
file is a report, displaying noise data in a client-friendly format. We
prepare a report, then lock the linked data and save it for that client
so the report won't be changed when another client's data is loaded
into Excel.

I can't get the macro to record the "links..." commands. I just ran the
macro recorder and did the following:
------------------------
EDIT
Links...
Shift-End (to select all links)
Click "Locked"
Click OK
Stop recording
----------------------------

Yet this is what was recorded (nothing)
--------------------
Sub LockLinks()
'
' LockLinks Macro
' Macro recorded 04/14/06 by Greg Guarino
'
End Sub
 
J

Jean-Guy Marcil

(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :
Word 97, Windows XP Home

I use the macro recorder to automate various tasks. I don't hand edit
the macros, except to remove a line here and there. I made a macro to
insert a Word file that has many links from an Excel sheet. The Word
file is a report, displaying noise data in a client-friendly format.
We prepare a report, then lock the linked data and save it for that
client so the report won't be changed when another client's data is
loaded into Excel.

Some action me do through some of the built-in dialog boxes are not recorded
by the macro recorder.

In your case, try this:

Dim myField As Field
Dim i As Long

With ActiveDocument
For i = 1 To .Fields.Count
If .Fields(i).Type = wdFieldLink Then
.Fields(i).LinkFormat.Locked = True
End If
Next
End With



--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
G

g

Je suis desolée, mais je ne comprend pas votre reponse. Je comprend le
Francais meilleur de VBA (un peu). :) En fait, je ne comprend VBA du
tout. J'ai essayé de copier-coller le texte que vous avez écrit dans
le "macro", mais il ne fonctionne pas. Peut-etre vous pourriez essayer
encore d'aider un homme ignorant?

Merci d'avance.

Greg Guarino
 
J

Jean-Guy Marcil

(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :
Je suis desolée, mais je ne comprend pas votre reponse. Je comprend le
Francais meilleur de VBA (un peu). :) En fait, je ne comprend VBA du
tout. J'ai essayé de copier-coller le texte que vous avez écrit dans
le "macro", mais il ne fonctionne pas. Peut-etre vous pourriez essayer
encore d'aider un homme ignorant?


Tu as essayé une macro comme celle-ci?

(En remplaçant

'
' LockLinks Macro
' Macro recorded 04/14/06 by Greg Guarino
'

par mon code.)

'_______________________________________
Sub LockLinks()

Dim myField As Field
Dim i As Long

With ActiveDocument
For i = 1 To .Fields.Count
If .Fields(i).Type = wdFieldLink Then
.Fields(i).LinkFormat.Locked = True
End If
Next
End With

End Sub
'_______________________________________


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
G

g

Jean-Guy Marcil said:
(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :
Tu as essayé une macro comme celle-ci?

(En remplaçant

'
' LockLinks Macro
' Macro recorded 04/14/06 by Greg Guarino
'

par mon code.)

Exactement. Le macro s'arrete a cette ligne:

.Fields(i).LinkFormat.Locked = True

Greg Guarino
 
J

Jean-Guy Marcil

(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :
Exactement. Le macro s'arrete a cette ligne:

.Fields(i).LinkFormat.Locked = True

Je présume que c'est le premier champ du document.

Mets ton curseur sur ce premier objet lié, fait ALT-F9 pour afficher le code
de champ.
Sélectionne le code (le texte entre les deux { }, présumément LINK quelque
chose ) et copie ce code.

Colle ce texte dans une réponse à ce message pour que je puisse voir de quel
type d'objet lié il s'agit.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
D

Doug Robbins - Word MVP

Possiblement, Je comprend le VBA meilleur de francais (un peu). :)

Essayez

Dim i As Long

With ActiveDocument
For i = 1 To .Fields.Count
If .Fields(i).Type = wdFieldLink Then
.Fields(i).Unlink
End If
Next
End With



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP


Jean-Guy Marcil said:
(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :
Tu as essayé une macro comme celle-ci?

(En remplaçant

'
' LockLinks Macro
' Macro recorded 04/14/06 by Greg Guarino
'

par mon code.)

Exactement. Le macro s'arrete a cette ligne:

.Fields(i).LinkFormat.Locked = True

Greg Guarino
 
G

g

Jean-Guy Marcil said:
(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :


Je présume que c'est le premier champ du document.

Mets ton curseur sur ce premier objet lié, fait ALT-F9 pour afficher lecode
de champ.
Sélectionne le code (le texte entre les deux { }, présumément LINK quelque
chose ) et copie ce code.

Colle ce texte dans une réponse à ce message pour que je puisse voir de quel
type d'objet lié il s'agit.
Merci beaucoup pour votre assistance. Je suis chez moi maintenant. Les
fichiers de MS Word sont a mon bureau. Mardi sera le prochain jour que
je travaillerai. J'essayerai encore a Mardi.

Bonne week-end!

Greg Guarino
 
J

Jean-Guy Marcil

Doug Robbins - Word MVP was telling us:
Doug Robbins - Word MVP nous racontait que :
Possiblement, Je comprend le VBA meilleur de francais (un peu). :)

Essayez

Dim i As Long

With ActiveDocument
For i = 1 To .Fields.Count
If .Fields(i).Type = wdFieldLink Then
.Fields(i).Unlink
End If
Next
End With

He does not want to unlink, but to lock the linked objects.... I cannot
fathom why the code I posted does not work....
Any ideas?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
G

g

Voici le code des objets liés:

LINK Excel.Sheet.8 "\\\\Al\\af my docs\\2260 octave grapher.xls"
"graph!R13C1" \a \t
LINK Excel.Sheet.8 "\\\\Al\\af my docs\\2260 octave grapher.xls"
"graph!R13C2" \a \t
LINK Excel.Sheet.8 "\\\\Al\\af my docs\\2260 octave grapher.xls"
"graph!R32C2" \a \t
LINK Excel.Sheet.8 "\\\\Al\\af my docs\\2260 octave grapher.xls"
"graph!R33C2" \a \t
LINK Excel.Sheet.8 "\\\\Al\\af my docs\\2260 octave grapher.xls"
"graph!R19C1" \a \t
LINK Excel.Sheet.8 "\\\\Al\\af my docs\\2260 octave grapher.xls"
"graph![2260 octave grapher.xls]graph Chart 12" \a \p


Merci d'avance,

Greg Guarino
 
G

g

Doug said:
Possiblement, Je comprend le VBA meilleur de francais (un peu). :)

I'm from New York City. I was responding to my Northern neighbor
Jean-Guy in French as a friendly gesture and in the hope that it might
make him more likely to help me out. :) But my first language is
English and I see that Jean-Guy has used the word "fathom" in one of
his posts, so I think he must speak English quite well.
Essayez

Dim i As Long

With ActiveDocument
For i = 1 To .Fields.Count
If .Fields(i).Type = wdFieldLink Then
.Fields(i).Unlink
End If
Next
End With

I just tried this. I get "runtime error 5941", "The requested member of
the collection does not exist". I posted the code from the links in my
document in another message on this thread. Help from any source is
appreciated.

Thanks in advance,

Greg Guarino
 
J

Jean-Guy Marcil

(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :
Voici le code des objets liés:

LINK Excel.Sheet.8 "\\\\Al\\af my docs\\2260 octave grapher.xls"
"graph!R13C1" \a \t
LINK Excel.Sheet.8 "\\\\Al\\af my docs\\2260 octave grapher.xls"
"graph!R13C2" \a \t
LINK Excel.Sheet.8 "\\\\Al\\af my docs\\2260 octave grapher.xls"
"graph!R32C2" \a \t
LINK Excel.Sheet.8 "\\\\Al\\af my docs\\2260 octave grapher.xls"
"graph!R33C2" \a \t
LINK Excel.Sheet.8 "\\\\Al\\af my docs\\2260 octave grapher.xls"
"graph!R19C1" \a \t
LINK Excel.Sheet.8 "\\\\Al\\af my docs\\2260 octave grapher.xls"
"graph![2260 octave grapher.xls]graph Chart 12" \a \p

My code (or Doug's) should work with these types of links.

Is it possible that you do not have access to the "Al\af my docs" folder or
that the Excel file is missing?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
G

g

Jean-Guy Marcil said:
(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :
My code (or Doug's) should work with these types of links.

Is it possible that you do not have access to the "Al\af my docs" folder or
that the Excel file is missing?

I was trying to run the macro on a different computer on the network
than where the files were. I just tried your code on the computer that
has the files. It does work, but there are two problems.

1. It is very, very slow. It took nearly 3 minutes on a document that
has 22 links.

2. It did not lock the last link, which is an Excel chart. All the rest
were links to the contents of individual Excel cells.

At this point it is quicker for the person writing the report to lock
the links manually. I don't mean this as a complaint, you have been
very generous with your time already. Thanks again.

Greg Guarino
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top