Re: VB/Word - Making lines read only

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

From: Jezebel (dwarves_at_heaven.com.kr)
Date: 08/27/04


Date: Fri, 27 Aug 2004 15:15:11 +1000


"Phillip Wu" <pwu@qantas.com.au> wrote in message
news:943cec75.0408262059.5c089fb7@posting.google.com...
> Hi,
>
> I'm trying to write an Visual Basic application that starts Microsoft
> Word to allow a user to edit a text file.
>
> However the first line is a header and the last line is a trailer and
> I don't want the user to delete these lines. Also when the user exits
> from Word (closes the file or exits Word) I want the control to be
> returned to the VB application so that I can update the trailer.
>
> I am new to VB with Word so please bear with me. There are not many
> resources on the Web to assist.
>
> What I need to know is:
> 1) Is there an easy way to make the line read-only? Line in this case
> is the same as the Sentences object. If not would I have to trap all
> the insert/replace/delete events and beep if the user is on the first
> or last line?

You can break the document in three sections: header, body, trailer, and
then protect the first and last. Not fool-proof, but if you don't mind
having section breaks in the document, it might be sufficient. There's no
other way to make parts of a document read-only. Forget about trapping the
insert etc events. Alternatively, don't worry about it while the user is
editing but check, in the Document_BeforeSave event, whether the header and
trailer are as you need them to be and correct if necessary.

>
> 2) Is there some sample code showing how I can start Word in VB AND
> take back control when the user closes the file?
>

Use early binding. Declare your Word application reference 'with events' and
put the appropriate event code in your VB app. However 'take back control'
is a slightly dubious concept in an object-oriented language like VB. But at
least your app is notified that the user has closed with the document or
quit Word.



Relevant Pages

  • Re: Convert GET to POST and Server.Transfer
    ... header values for a manual post - does not work, as there is only 1 request ... PostBacks and treating your app like a persistant page navigation app ... grab these POSTed values by referencing their control names, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Combobox Display Problem
    ... Header section of the Sub-form, and it was invisible when run as I mentioned. ... ' Find the record that matches the control. ... Header section of the form (subform), ... The Control Source for cboItem on fsubGroup is chrItem, ...
    (microsoft.public.access.forms)
  • Re: ToolTipText and the ListView control in VB6
    ... control setup. ... '* Description: Process MouseMove event. ... If .ToolTipText objListItem.Key Then ... '' the mouse must be in the header area. ...
    (microsoft.public.vb.controls)
  • RE: Filter records based on user input
    ... No, I did not put it in the header, I just uses an unbound text box in the ... I thought that the bookmark line would set the focus to the control in the ... which would filter your form based on the text in the textbox. ... It should filter the records as the user types the number. ...
    (microsoft.public.access.formscoding)
  • Re: Another GridView Bug -> PagerSettings.Visible
    ... GridView control is based on templates ... stage is the only time you can build the control structure. ... set to true and capture the pager row ... note that the header should be enabled when the pager is visible and ...
    (microsoft.public.dotnet.framework.aspnet)