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 / May 2006

Tip: Looking for answers? Try searching our database.

Error 4198 wdfieldlink and wdfielddocvariable - breaking & unlinki

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JAG777 - 31 May 2006 10:22 GMT
I have a word template which has a number of graphs (wdfieldlinks created by
inserting manual Excel graph links with copy/paste special/link) and
variables taken from a user form (wdfielddocvariable).
I have tried a number of ways to get the newly created word doc to update
the graphs and docvariables, and then break the links - but have reached a
dead-end.
The unlink method, if sent to the fields property of the active document,
appears to stop the update method for wdfieldlinks, but not
wdfielddocvariables - so I end up with a doc that has incorrect graphs - but
correct, updated data. So, I have used the following code after the general
update command in order to break the links / unlink the links by field type:

Activedocument.fields.update

For Each fldElement In .Fields
     
       Select Case fldElement.Type
         Case wdFieldLink
           fldElement.LinkFormat.BreakLink
         Case Else
           fldElement.Unlink
       End Select
     
Next

This gives me the error 4198.

I am new to VBA programming and am learning from books (which I'm finding
can be quite vague) so apologies if this is an elementary problem. Any help
would be very gratefully received.

jag777
Dave Lett - 31 May 2006 16:11 GMT
Hi Jag,

I can't reproduce your issue. I can unlink all fields (including Link
fields) using Unlink. I can also unlink the fields using the Unlink and
BreakLink routine that you have.

Error 4198 is a basic Command Failed  error message. Can you click a debug
button on this message? If so, what line in the compiler is highlighted?

Dave

>I have a word template which has a number of graphs (wdfieldlinks created
>by
[quoted text clipped - 33 lines]
>
> jag777
JAG777 - 31 May 2006 16:35 GMT
Hi Dave,

Thanks for your input.

The line of code that fails is 'fldElement.LinkFormat.BreakLink' in the
select case statement.
I can get the links to unlink or break (depending on type) using template
code to manipulate the active document, but the graphs (link fields) don't
show the new figures. If I don't unlink - they do - probably best if I
explain this a little more...

I have an XL wkb and the word .dot template, which has a user form that
starts with the new document event.
The form takes a series of figures, which are used to do two things:

1 - Update a group of docvariable fields through the new word document
2 - Used to update the dataset of the graph in the XL wbk.

The above works fine - i.e. the XL wkb's state is changed as expected after
running the macro and the docvariable fields are all updated accordingly.

What I am trying to achieve (in code within the template) is the equivelent
of right-clicking on each graph (within the newly created doc ), updating the
link (to reflect the changes made via the word to Excel automation) and break
the links.
If I don't use the unlink method, then I get updated graphs and docvariables
- but still have live links (which although is fit for purpose, is not ideal
and looks messy f the user types on a link). If I do use the unlink method, I
get updated docvariables, but graphs as per the template (i.e. they don't
update to the new dataset which is working in the XL wkb?) - hence, my poor
attempt to either break link or unlink based upon the field type.

Hopefully this makes some sense!

Just to add - if you try to emulate the same issue without the use of a
template (i.e. code it within ThisDocument) it seems to work fine. It's
something to do with the template - I think anyway...?

Regards,

jag777

> Hi Jag,
>
[quoted text clipped - 44 lines]
> >
> > jag777
 
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.