Possible to automatically change style when new content is typed?

S

sdjwalls

Hello,

In our template, we have some instructions in a style called "Instruction
Style". Currently, if a user places his cursor somewhere in these
instructions and starts to type actual content (if he were trying to
overwrite the instructions, for example), the style remains "Instruction
Style" when it should be something else, like "Body Text". The user can
manually change the style, but if he forgets, the content he's typed risks
getting removed by a macro that removes the "Instruction Style" content later
(to ensure that instructions don't end up in a published doc).

Is there a way to do this in the template, either with VBA or something
else? I'd like to avoid applications events, etc. as these templates are
stored and distributed on a sharepoint server and I don't want them to get
too complicated.

Thank you!
 
J

Jean-Guy Marcil

sdjwalls was telling us:
sdjwalls nous racontait que :
Hello,

In our template, we have some instructions in a style called
"Instruction Style". Currently, if a user places his cursor somewhere
in these instructions and starts to type actual content (if he were
trying to overwrite the instructions, for example), the style remains
"Instruction Style" when it should be something else, like "Body
Text". The user can manually change the style, but if he forgets, the
content he's typed risks getting removed by a macro that removes the
"Instruction Style" content later (to ensure that instructions don't
end up in a published doc).

Is there a way to do this in the template, either with VBA or
something else? I'd like to avoid applications events, etc. as these
templates are stored and distributed on a sharepoint server and I
don't want them to get too complicated.

Thank you!

Another option would be to remove only the instruction paragraphs that have
not been modified by the user.

Presumably, when a user creates a document from the template, the
instructions are always the same.
So, store the instructions in your code (you could use DocumentVariabel in
the template or AutoText), then, instead of deleting according to style
only, look for paragraphs that have the style you want and check if the
content has been modified, if so, do not delete it.
 
S

sdjwalls

Hi Jean-Guy,

Thanks for replying to my question. I looked into both AutoText and doc
variables, however, since the text content changes quite a bit throughout the
doc, that wasn't really feasible. However, your response got me thinking and
I figured out a solution (for anyone else who'd be interested). Basically, I
lock down the content of the styles (works well in Office 2007, not sure
about other versions):

1. Developer -> Protect Document, click on "Editing Restrictions" and "Allow
only this type of editing..." (with "No changes..." selected).
2. Ctrl-A to select the whole doc and click on "Everyone" in Exceptions
3. Bring up the Styles pane, select all instances of particular styles to
protect, then unclick "Everyone" in Exceptions
4. Start Enforcing Protection (and turn off highlighting...)

I then have a DelInstructions macro that has as its first 2 lines:
ActiveDocument.Select
Selection.Editors.Add wdEditorEveryone
This then allows me to delete everything of that style before publishing.

Sounds more involved than it is, but maybe that'll help someone else.

Cheers...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top