Advanced
Sun Apr 15 03:52:01 CDT 2007
Dear George,
It still didn't work out for me.
When the cursor gets into the Customer Node it sets the security to
everyone, as expected, but when you press the 'backspace' after you deleted
the text inside the node, it selects the xml-tag itself and thén, when you
press the 'backspace' again it removes the xml-tag from the document.
Could the problem depends on my xml-nodes?
The scheme is attached to the template.
I am developing this all in VSTO2005
The customer node is build as following;
<Customer>
<Company></Company>
<Salutation></Salutation> <FirstName></FirstName> <LastName></LastName>
</Customer>
<CustomerAddress>
<Street></Street>
<PostalCode></PostalCode> <Place></Place>
<Country></Country>
</CustomerAddress>
Below is the scheme of the document;
[code]
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="XSDSchema1"
targetNamespace="
http://tempuri.org/XSDSchema1.xsd"
elementFormDefault="qualified" xmlns="
http://tempuri.org/XSDSchema1.xsd"
xmlns:mstns="
http://tempuri.org/XSDSchema1.xsd"
xmlns:xs="
http://www.w3.org/2001/XMLSchema">
<xs:element name="Customer" type="CustomerType" />
<xs:element name="Customer_Address" type="CustomerAddressType" />
<xs:element name="FrontPageImage" type="xs:base64Binary"
xmime:expectedContentType="image/gif"
xmlns:xmime="
http://www.w3.org/2005/05/xmlmime" />
<xs:element name="Employee" type="EmployeeType" />
<xs:element name="Index" type="xs:string" />
<xs:element name="FrontLetter" type="xs:string" />
<xs:element name="Content" type="xs:string" />
<xs:complexType name="CustomerType">
<xs:sequence>
<xs:element name="Company" type="xs:string" minOccurs="1"
maxOccurs="unbounded" />
<xs:element name="Salutation" type="xs:string" minOccurs="1"
maxOccurs="1" />
<xs:element name="Firstname" type="xs:string" minOccurs="1"
maxOccurs="1" />
<xs:element name="Lastname" type="xs:string" minOccurs="1"
maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="CustomerAddressType" mixed="true">
<xs:sequence>
<xs:element name="Street" type="xs:string" minOccurs="1" maxOccurs="1"
/>
<xs:element name="Postalcode" type="xs:string" minOccurs="1"
maxOccurs="1" />
<xs:element name="Place" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="Country" type="xs:string" minOccurs="0"
maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="BEaddress" mixed="true">
<xs:complexContent>
<xs:extension base="CustomerAddressType">
<xs:sequence>
<xs:element name="zipcode" type="xs:positiveInteger"/>
<xs:element name="Place" type="xs:string" minOccurs="1"
maxOccurs="1" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="UKaddress" mixed="true">
<xs:complexContent>
<xs:extension base="CustomerAddressType">
<xs:sequence>
<xs:element name="zipcode" type="xs:positiveInteger"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="NLaddress" mixed="true">
<xs:complexContent>
<xs:extension base="CustomerAddressType">
<xs:sequence>
<xs:element name="zipcode" type="xs:positiveInteger" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="EmployeeType">
<xs:sequence>
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="Email" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="Telephone" type="xs:string" minOccurs="1"
maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:schema>
[/code]
"Advanced" wrote:
> George,
>
> Thank you very much for your input on this. I will try it right away and let
> you know if it worked out for me.
>
> Kind regards from The Netherlands,
> Richard
>
>
> "GeorgeW" wrote:
>
> > You probably should not unprotect the whole document.
> >
> > You can just add editors to your XMLNode
> >
> > For example, to insert editors
> > For i = 1 To ActiveDocument.XMLNodes.Count
> > ActiveDocument.XMLNodes(i).Range.Editors.Add (wdEditorEveryone)
> > Next
> >
> > to remove editors
> > For i = 1 To ActiveDocument.XMLNodes.Count
> > ActiveDocument.XMLNodes(i).Range.Editors(wdEditorEveryone).Delete
> > Next
> >
> > Hope this helps.
> >
> > "Advanced" wrote:
> >
> > > I am creating a Word Template in VSTO by attaching a schema to it and apply
> > > XML tags in it. The user can fill in the document by several taskpanes.
> > > The document in general is protected but when a user selects an xml-node I
> > > use the _ContextEnter to unprotect the document and the _ContextLeave to
> > > protect the document again.
> > >
> > > If the document is unprotected, the user can delete the content within the
> > > xml tag (for editing without using the taskpane) but the user can ALSO delete
> > > the xml-tag itself which should not happen at all. After the xml-tag is
> > > deleted the document goes in protectionmode but obvious this is too late
> > > because the tag shouldn't be removed at all.
> > >
> > > Anybody knows a solution or workaround for this?
> > >
> > > Regards,
> > >
> > > Richard
> > > The Netherlands
> > >
> > >