Re: Using Events with the Application Object

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jim Gordon MVP (goldkey74_at_WarmerThanWarmMail.com)
Date: 05/18/04


Date: Tue, 18 May 2004 19:25:57 -0400

Hi Alan,

The chances that Mac Office will support VBA version 6 are zero in the
foreseeable future. VBA itself will morph into VBA.Net. After that happens
the Mac Business unit will have to analyze how to deal with automation and
see what they can do.

The commands you are using seem to be from VBA version 6. In version 5 the
protection commands are document level:
Protection Type Required Long. The protection type for the specified
document. Can be one of the following WdProtectionType constants:
wdAllowOnlyComments, wdAllowOnlyFormFields, wdAllowOnlyRevisions, or
wdNoProtection.

You can protect forms at the section level.

I don't know a way to intercept the keyboard to stop people from selecting
and changing the document. Maybe you could have a hidden copy of the
document and work with that somehow to keep a document without changes. You
could compare text strings.

You might want to try one of the microsoft.public.word.vba newsgroups to see
if there are code samples there that might be of help. Anything that works
in VBA version 5 should be fair game for you.

-Jim

Quoting from "Alan Riley" <kandariley@ozemail.com.au>, in article
#n8AFFJPEHA.560@TK2MSFTNGP10.phx.gbl, on [DATE:

> Hi Jim
>
> Thanks for the reply. That would explain it - do you know if/when they will
> upgrade to VB6 for Mac?
>
> I am developing automated templates that enforce a standard by providing the
> users with a range of tools whilst preventing them (as far as possible) from
> making unwanted modifications. The easiest ways I found to do this was by:
>
> - Protecting vulnerable areas such as Title Pages, Headers/Footers, Table of
> Contents etc using sections;
> - Providing a VBA data entry form that allows the user to populate key
> document details in protected areas;
> - Automating additonal functionality through custom toolbars.
>
> Unfortunately, the Word functionality that is disabled, when protection is
> turned on, is not restricted to the protected sections, eg. 'spell check
> underlining', Page Setup, Track Changes etc. are not available in the rest
> of the document. Additional coding will get round some of this, ie. custom
> macros to peform the actions with 'unprotect' before processing, but this
> opens me up for heaps more testing and support.
>
> Without protection in these sections, users can overwrite fields, remove
> bookmarks, change styles and layouts etc, thus preventing the data entry
> form and automation from working as efficiently (throwing up a comparible
> headache to that above).
>
> Anyway, I found a workable solution (in Word 2000 for Windows atleast), that
> meant I could remove the protection but still prevent users from getting
> into the vulnerable sections. The WindowSelectionChange event allows you to
> check where the selection is, what it contains and whether the user should
> be allowed to work there. If in an undesirable area, the selection can be
> moved to an area of my choice. eg.
>
> Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
>
> If Sel.Information(wdActiveEndSectionNumber) = 1 Then
> Msgbox "Use Data Entry Form"
> Selection.GoTo What:=wdGoToSection, Count:=2
> End If
>
> End Sub
>
> This doesn't work on the Mac, hence my problem.
>
> The reason I was thinking about EditCut, EditClear or EditPaste was because
> they are events that I can trap to determine where the selection was before
> continuing. But the main culprit for disruption is over typing on the
> selection (for which there is no menu event to usurp - or is there ??).
>
> Thanks again for your help. Any other suggestions would be great.
>
> Alan Riley
> ADR Software
>
> "Jim Gordon MVP" <goldkey74@WarmerThanWarmMail.com> wrote in message
> news:BCCEDA88.A522%goldkey74@WarmerThanWarmMail.com...
>> Hi Alan,
>>
>> The visual basic model for Word on the Mac is very close to VBA 5 for
>> Windows. If WindowSelectionChange was something new in VBA 6 then it won't
>> work on Macintosh versions of Word. I did not find WindowSelectionChange
>> in the object editor for Mac Word. What are you trying to accomplish with
>> this command?
>>
>> I'm not entirely sure whether you want to delete text or cut it to the
>> clipboard. Cut is different from Delete. At it's simplest, you can use
>> Selection.Delete to delete selected text. You can move text to and from
> the
>> clipboard as well as to and from objects that accept text such as text
> boxes
>> and autoshapes. You can also put text into variables and arrays within
>> Visual Basic so that you can store it and use it later in your code so you
>> don't have to worry about losing text that you remove but might want to
> use
>> later on. You could create one or more hidden Word documents to use as
>> storage for text or objects.
>>
>> I hope this answer helps somewhat.
>>
>> -Jim
>>
>> --
>> Jim Gordon
>> Mac MVP
>>
>> MVPs are not Microsoft Employees
>> MVP info http://mvp.support.microsoft.com/
>>
>> Quoting from "Alan Riley" <kandariley@ozemail.com.au>, in article
>> uvR#Yt$OEHA.2580@TK2MSFTNGP09.phx.gbl, on [DATE:
>>
>>> Hello All
>>>
>>> Does anyone know if the WindowSelectionChange application event should
> be
>>> available within Word for Mac 2001 & X, or how to get it working, as it
>>> won't work for me? I have searched high and low for information on it
> but
>>> have found nothing.
>>>
>>> I've been using it successfully in Word for Windows to ensure that
> fields,
>>> bookmarks and other sensitive items are not overwritten. It allows the
> new
>>> selection to be analysed before the user can to do anything with it. I
> have
>>> already tried section protection to achieve the same thing (which works
> as
>>> far as protection is concerned), but it disabled too much functionality
> (in
>>> the unprotected sections !!).
>>>
>>> I could also use the EditCut and EditClear events to stop deletion but
> the
>>> main danger is overtyping, so I need something extra to stop a damaging
>>> action. Is there any other way to achieve this, eg. an "InsertText"
> event??
>>>
>>> Any help would be much appreciated.
>>>
>>> Thanks
>>> Alan Riley
>>> ADR Software
>>>
>>>
>>
>>
>>
>
>

-- 
Jim Gordon
Mac MVP
MVPs are not Microsoft Employees
MVP info http://mvp.support.microsoft.com/


Relevant Pages

  • Re: Using Events with the Application Object
    ... Unfortunately, the Word functionality that is disabled, when protection is ... the selection can be ... This doesn't work on the Mac, ... If WindowSelectionChange was something new in VBA 6 then it won't ...
    (microsoft.public.mac.office.word)
  • Re: Using Events with the Application Object
    ... We know very definitely that they will *not* upgrade VBA on the Mac. ... the selection can be ...
    (microsoft.public.mac.office.word)
  • Re: Using Events with the Application Object
    ... I think I'll have to play around with protection a bit more - see if I can ... > The chances that Mac Office will support VBA version 6 are zero in the ... the selection can ... >> Alan Riley ...
    (microsoft.public.mac.office.word)
  • Re: Using Events with the Application Object
    ... If WindowSelectionChange was something new in VBA 6 then it won't ... in the object editor for Mac Word. ... > far as protection is concerned), but it disabled too much functionality (in ...
    (microsoft.public.mac.office.word)
  • Using Events with the Application Object - Word for Mac
    ... Does anyone know if the WindowSelectionChange application event should be ... available within Word for Mac 2001 & X, or how to get it working, as it ... selection to be analysed before the user can to do anything with it. ... far as protection is concerned), but it disabled too much functionality (in ...
    (microsoft.public.word.vba.general)