[AccessD] OT: Word VBA - skip code?

Roz Clarke roz.clarke at donnslaw.co.uk
Tue Jul 22 11:11:45 CDT 2003


Charles

< And of course none of the precedent letters have a check in the OnOpen
event to see if a parameter was passed to indicate whether to execute
the remaining code or not! >

Indeed. :)

Unfortunately the code in the precedent letters does funky stuff like
inserting & deleting bookmarks, deleting table rows and updating header
entries & status codes. I cannot, cannot, cannot afford to have that code
run. When manually amending a precedent, we tend to allow it and then 'Undo'
til we caint undo no more, but I can't code for that because to automate the
'UndoAction' method, you need to know the name of a form that performed the
action (according to the help file; I haven't tried it yet). Forms in the
precedents are all differently named.

I will try Marcus' suggestions - using SendKeys to mimic the holding of the
Shift key might work as might changing the security levels. That's fun &
games for tomorrow though - off home now.

Roz

-----Original Message-----
From: Wortz, Charles [mailto:CWortz at tea.state.tx.us] 
Sent: 22 July 2003 14:46
To: Access Developers discussion and problem solving
Subject: RE: [AccessD] OT: Word VBA - skip code?

Roz,

And of course none of the precedent letters have a check in the OnOpen
event to see if a parameter was passed to indicate whether to execute
the remaining code or not!  So how much damage will happen if you let
all those OnOpen events execute?  If they write entries into an audit
table or something similar, you could make the table unavailable while
your code below is executing, thus the OnOpens will error out and you
could trap the errors.  You will have to determine whether it is cheaper
in time and effort to clean up after all the OnOpens or to prevent them.
Good luck.

Charles Wortz 
Software Development Division 
Texas Education Agency 
1701 N. Congress Ave 
Austin, TX 78701-1494 
512-463-9493 
CWortz at tea.state.tx.us 
-----Original Message-----
From: Roz Clarke [mailto:roz.clarke at donnslaw.co.uk] 
Sent: Tuesday 2003 Jul 22 08:21
To: AccessD (AccessD at databaseadvisors.com)
Subject: [AccessD] OT: Word VBA - skip code?

Hello everyone
Another nasty problem for you. J
I have been asked to insert an additional line into all our precedent
letters (there are a few thousand). So far so doody; I can find the
right insertion point and put the line in.

What's stopping me is that many of the precedent letters have code of
their own. Somewhere in the loop below, I need to prevent any code in
the Open event of the document from running.

If Application.FileSearch.Execute > 0 Then
 For i = 1 To Application.FileSearch.FoundFiles.Count
        strName = Application.FileSearch.FoundFiles(i)
        Set objDoc = wrdapp.Documents.Open(strName)
        If objDoc.ReadOnly = False Then
            Set myRange = objDoc.Content
            myRange.Find.Execute FindText:=strFindText, Forward:=True
            myRange.InsertAfter strTestText
        End If
        doc.Close
 Next i
The procedures I need to kaibosh all have the same name: Document_Open
(obviously), if that helps. How can I get my code to bypass those
procedures??
Yours hopefully
Roz
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list