Retrieve header data

M

Mark

Hi,
I am attempting to extract a portion of a document's
header data which appears to work correctly in the debug
window (I only need line one of two lines - the lines are
seperated by a carriage return). However, when I try to
pass the data to Access (97) I get a Dr.Watson error. The
relevant code is posted below. Any help would be greatly
appreciated! Thanks.
Mark

With ContractRecord
.AddNew

ActiveDocument.Unprotect
.Fields("CONTRACT_TYPE") =
ActiveDocument.Sections(1).Headers
(wdHeaderFooterPrimary).Range.Paragraphs(1)--> Dr.Watson
ActiveDocument.Protect
Type:=wdAllowOnlyFormFields, NoReset:=True
.Update
End With
ContractRecord.Close
Set ContractDataBase = Nothing
 
J

Jezebel

Access may be complaining that you're trying to put a Word.Paragraph object
into a text field.
Try ...Paragraphs(1).Range.Text
 
M

Mark

Thanks, that did the trick!
-----Original Message-----
Access may be complaining that you're trying to put a Word.Paragraph object
into a text field.
Try ...Paragraphs(1).Range.Text





.
 
M

Malcolm Smith

Apart from Jezebel's excellent answer you may have to consider that there
may not be a Primary header and in this case the object won't exist and
therefore you will have to trap for errors.

When I have done this in the past I have had to seek for all types of
headers and then work out what I have got.

Does this (pre-caffeine) ramble make sense? If not, let me know and I'll
give it another shot.

- Malc
www.dragondrop.com
 

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