I am running word from access - using msoffice2000, winxp

I have 22 docs with bookmarks in them. I need to fill in the bookmarks
from my access app.

Everything works as expected on 18 of the 22 files.

The other 4 files cause all kinds of problems. I have set the
recordset to just access these 4 files, wondering if I was over-taxing
the whole system, but even if they are the only 4 files, they cause
problems.

Here are the problems.
If I try to do all 22 files, I get the 18 files correct, then the app
stops, everything is in 'not responding' and I have to shut it all
down.

If I try to do just the 4 rogue files, the routine that sets the
bookmarks gets the 4 files in a recordset, opens them, skips over the
portion of the routine that sets the bookmarks.text and closes them
back up, this time without any 'not responding' system problems. I
have checked the docs, and all bookmarks are actually present.

Using debug.print, I see the routine set all 18 files but then it
fails on the first of these 4 files. The debug.print suggests that the
app is working on the files in an ascending alpha sort, and it does
the good 18, and then crashes on the first of the 4 bad files, which
is located in the middle of the alpha sort. I am dumbfounded at this
action, but am wondering if I perhaps have four corrupted files. I
thought I would beg some information before just jumping in and
recreating these files.

Is there something I can do about this short of recreating the files?

Thanks for your expertise. I appreciate it a great deal.

Re: Bookmarks by Doug

Doug
Thu Sep 23 18:41:16 CDT 2004

From your description of what happens when you run the routine over just
those four files, there has to be something about them that is causing the
problem. Can't tell from the information that you have provided just what
it is, but that is where you need to look.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"Joanne" <JoBobBuss@sbcglobal.net> wrote in message
news:ePh3oXboEHA.3252@TK2MSFTNGP14.phx.gbl...
>I am running word from access - using msoffice2000, winxp
>
> I have 22 docs with bookmarks in them. I need to fill in the bookmarks
> from my access app.
>
> Everything works as expected on 18 of the 22 files.
>
> The other 4 files cause all kinds of problems. I have set the
> recordset to just access these 4 files, wondering if I was over-taxing
> the whole system, but even if they are the only 4 files, they cause
> problems.
>
> Here are the problems.
> If I try to do all 22 files, I get the 18 files correct, then the app
> stops, everything is in 'not responding' and I have to shut it all
> down.
>
> If I try to do just the 4 rogue files, the routine that sets the
> bookmarks gets the 4 files in a recordset, opens them, skips over the
> portion of the routine that sets the bookmarks.text and closes them
> back up, this time without any 'not responding' system problems. I
> have checked the docs, and all bookmarks are actually present.
>
> Using debug.print, I see the routine set all 18 files but then it
> fails on the first of these 4 files. The debug.print suggests that the
> app is working on the files in an ascending alpha sort, and it does
> the good 18, and then crashes on the first of the 4 bad files, which
> is located in the middle of the alpha sort. I am dumbfounded at this
> action, but am wondering if I perhaps have four corrupted files. I
> thought I would beg some information before just jumping in and
> recreating these files.
>
> Is there something I can do about this short of recreating the files?
>
> Thanks for your expertise. I appreciate it a great deal.



Re: Bookmarks by Joanne

Joanne
Fri Sep 24 06:24:03 CDT 2004

Hey Malcom, I'm Baaaack!
You helped me write this code in the first place when I couldn't get
the recordset and didn't know how to access the records after I got
the recordset.
Well, all of that works beautifully, and I have implemented that type
of routine in other aspects of this app.(thank you, thank you, thank
you!)
Here is some of the code in the routine (I'm not going to burden you
with the setting of all the bookmarks - they work fine on the 18 docs
anyway)

This word automation from access office 2000 winxp
Function SetBookmarks()
Dim oWordapp As Object
Dim oDocName As Object
Dim oRst As DAO.Recordset
Dim BsSql As String 'sql stmt to get docs with bookmarks
Dim sFilename As String
'Open instance of MSWord
Set oWordapp = CreateObject("Word.Application")
oWordapp.Visible = True
'Create recordset using a sql query
'sql statment is saying get the file list from table named
'tblDocumentList'
'using the field 'DocNamePath' and choosing only files containing
bookmarks
BsSql = "SELECT tblDocumentList.DocNamePath FROM tblDocumentList" &
_
" WHERE (((tblDocumentList.Bookmarks) = True))"

'Open the recordset that is based on the return of the sql query
Set oRst = CurrentDb.OpenRecordset(BsSql)

'********************************************************
'Code to send recordset to immediate window
'Do Until oRst.EOF
'Debug.Print oRst.Fields("DocNamePath")
'oRst.MoveNext
'Loop 'the docs are all there as expected
'***********************************************************

'Check for records in recordset. If there are records, do until end
of file
If Not oRst Is Nothing Then
Do While Not oRst.EOF
sFilename = "" & oRst("DocNamePath")


'If the file is actually there (checking in case someone deleted it)
If Len(Dir$(sFilename)) > 0 Then

'open doc and if it opened successfully
Set oDocName = oWordapp.Documents.Open(sFilename)
If Not oDocName Is Nothing Then

'Set the bookmarks in the doc
With oWordapp.ActiveDocument.Bookmarks
If oWordapp.ActiveDocument.Bookmarks.Exists("FName") = True Then
.Item("Fname").Range.Text = Nz(Me!FName, "")
End If
If oWordapp.ActiveDocument.Bookmarks.Exists("Midinit") = True Then
.Item("MidInit").Range.Text = Nz(Me!Midinit, "")
End If
If oWordapp.ActiveDocument.Bookmarks.Exists("FNameMidInit") = True
Then
.Item("FNameMidInit").Range.Text = Nz(Me!FNameMidInit, "")
End If
oDocName.Save
DoEvents
oDocName.Close
Set oDocName = Nothing
'Get the next file in recordset and run thru the above loop again
oRst.MoveNext
End If
End If
Loop
End If
oWordapp.Quit
oRst.Close
Set oWordapp = Nothing
Set oDocName = Nothing
Set oRst = Nothing
End Function

Like I said before, in trying to troubleshoot this myself I did try
the routine on only the 4 docs in question, and it simply skips the
entire set of code that sets the bookmarks in the other 18 docs. I
have checked the 4 docs and the bookmarks are firmly in place there.

What do you think Malcoml?
Thanks for your time and expertise
Joanne

Malcolm Smith wrote:

>Can you show us a sample of your code?