Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Section Break on Clipboard? (Word XP)

    Hi, all.
    Here at work, there are authors who have created documents from a template that I built. This template uses section- and document-protection (ProtectionType=wdAllowOnlyFormFields) to lock people out of certain sections, and initially sets the ProtectedForForms property for each particular section.

    But one problem that arises is that people working with this file have been pasting large amounts of text from the clipboard, and sometimes this text includes section breaks. Since Word's defaults are that a section's "Protected" property is automatically set to "True," the newly pasted sections become protected by default. (And, since I don't provide the users with the password, they end up pasting sections into a document that they then can't edit.

    Since I don't really want them copying and pasting section breaks at all (for formatting reasons), and since there's no way I can effectively persuade them to stop doing it, I thought I'd try to remedy the problem by hijaaking the Paste command. My initial thoughts are that I could just check the contents of the clipboard when they paste, and if there are any section breaks in it, alert them that the section they are pasting will be un-editable. (Is there a better adjective for that?) I'd thought about just stripping it out, but I also think that it might be entirely possible that they are pasting text with multiple section breaks, and that might be more than I'm willing to tackle.

    At any rate, I've investigated using the dataobject.GetFromClipboard and the dataobject.GetText methods, but I can't figure out how to identify whether the clipboard contains a Section Break. Should I even be checking the resulting .GetText string, or is that unreliable since it is "just a string"?

    Any ideas?
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Section Break on Clipboard? (Word XP)

    GetText will just retrieve the plain text, a section break will become a carriage return/line feed.

    I don't know if it is feasible to paste the contents of the clipboard, then investigate the added part of the document.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Section Break on Clipboard? (Word XP)

    Following on Hans' suggestion, perhaps creating a new hidden document, pasting there and checking the .Sections.Count is a "quick and dirty" way of finding out?

  4. #4
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Section Break on Clipboard? (Word XP)

    Alternatively, your Paste hijack could go ahead and do the paste and then see if the number of sections in the document has increased. If so, you could immediately present your dialog to the user and your code could then do an Undo of the paste, depending on the user's response.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •