T
Todd
I have code that creates a Word document and, based on several criteria,
uses includetext fields to bring in data from several other files. That all
works perfectly. Next, I need the code to "unlink" the fields so that the
document becomes static (doesn't rely other files anymore). I know how this
code should look like in Word's VBA, but I'm not sure how to get it to work
from Access. Here is how the code would look in Word...
-------------------Beginning Code----------------
'Unlink fields to make document static (except for TOC)
Dim rngDoc As Range
Dim F As Field
Dim oDoc As Document
Dim aTOC As TableOfContents
For Each rngDoc In oDoc.StoryRanges
For Each F In rngDoc.Fields
If F.Type = wdFieldIncludeText Then
F.Unlink 'Unlinks INCLUDETEXT fields only...
End If
Next F
While Not (rngDoc.NextStoryRange Is Nothing)
Set rngDoc = rngDoc.NextStoryRange
For Each F In rngDoc.Fields
If F.Type = wdFieldIncludeText Then
F.Unlink 'Unlinks INCLUDETEXT fields only...
End If
Next F
Wend
Next rngDoc
--------------------Ending Code--------------------
Here is the code I'm using to start the Word doc...
-------------------Beginning Code----------------
Dim objWord As Word.Application
Set objWord = CreateObject("Word.Application")
With objWord
.........
End with
--------------------Ending Code--------------------
Thanks in advance for your help!!!
uses includetext fields to bring in data from several other files. That all
works perfectly. Next, I need the code to "unlink" the fields so that the
document becomes static (doesn't rely other files anymore). I know how this
code should look like in Word's VBA, but I'm not sure how to get it to work
from Access. Here is how the code would look in Word...
-------------------Beginning Code----------------
'Unlink fields to make document static (except for TOC)
Dim rngDoc As Range
Dim F As Field
Dim oDoc As Document
Dim aTOC As TableOfContents
For Each rngDoc In oDoc.StoryRanges
For Each F In rngDoc.Fields
If F.Type = wdFieldIncludeText Then
F.Unlink 'Unlinks INCLUDETEXT fields only...
End If
Next F
While Not (rngDoc.NextStoryRange Is Nothing)
Set rngDoc = rngDoc.NextStoryRange
For Each F In rngDoc.Fields
If F.Type = wdFieldIncludeText Then
F.Unlink 'Unlinks INCLUDETEXT fields only...
End If
Next F
Wend
Next rngDoc
--------------------Ending Code--------------------
Here is the code I'm using to start the Word doc...
-------------------Beginning Code----------------
Dim objWord As Word.Application
Set objWord = CreateObject("Word.Application")
With objWord
.........
End with
--------------------Ending Code--------------------
Thanks in advance for your help!!!