views:

326

answers:

2

Hi There

First of all I'm going to state right out that I've never worked with VB in the context of coding macros before - my skills lie in other areas (PHP, Javascript, getting there with C#, etc). However, I've been asked by a colleague to lock down a document so that the user cannot change font faces, sizes or colours but does still have access to bold, italic, underline etc.

I started out by protecting the document and restricting formatting but this is far too restrictive - effectively only allowing the user to apply premade styles - which is going to be unintuitive for the users who are not used to working with styles.

So I've resorted to trying to writing a macro to do the job, but unfortunately I'm at the really pointy end of the learning curve and I honestly don't know where to start.

You're going to laugh at me but so far this is all I have in my ThisDocument.

Private Sub Document_Open()

End Sub

Ermmmm... help!

Cheers

Iain

A: 

I think you could write a macro that removed tools from the toolbar, menus, maybe even keyboard shortcuts. Not sure how you'd reverse it though when they opened another document.

Maybe a better solution is to use an application to edit only certain text fields that you define and which ultimately change text in a word document?

Matthew Lock
A: 

Iain, this is a pretty common need. Here's a good information page on what will get you started: Using VBA to Control Built-In Commands in the 2007 Office System

Otaku
Hi Otaku. Sorry for the late response, I asked the question a while ago and ended up coming at the problem from another angle. However, your response is very useful and I will keep it saved for whenever I have to do this sort of thing again. VBA is really not my strong suit, haha :). Thanks very much for taking the time to respond to my question, very much appreciated.- Iain
Iain Fraser