Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA IN WORD - ANY HELP IS APPRECIATED 1

Status
Not open for further replies.

txgeekgirl1

Programmer
Sep 10, 2009
85
US
Hi Folks!

So I have been tasked with trying to make a word doc function like a lockable database form but am running into issues.

Task - create 3-5 fields with input.

Create a button that when clicked the 3-5 fields lock so that entries cannot be changed and enable a Word signature block.

Create a second button that wipes the signature if clicked to edit the form fields (open form fields)

Here is the deal - In Access we name controls and therefore can code them in VBA. In Excel, we have named cells or values and can code them in VBA.

In Word - we have jack! Nothing - that I can find to differentiate one text box from another.

Has anyone ever coded backend VBA in Word - if so - can you please help me?
 
Bookmarks or docvariables are not "fields with input" and are not lockable. ContentControls or older formfields may work. They certainly work with VBA.

Gerry
 
DocVariables is NOT what I am looking for - I need to be able to call a named field - in Access it would be something like me.tbMyField.enabled = false

JACK hasn't been good since season 3 when they let his snotty little daughter work for him - not applicable in real life.

Gerry - I will look at ContentControls
 
Oh! Content Controls.

I was not aware of those. Useful indeed. In fact I've just incorporated them into something I'm working on.
 
So - these controls - made off the developer toolbar - unlike Access or Excel - have NO Name, No identifying information. In WORD are you just not able to backcode the controls like you can in Access and Excel? I mean - I think it's crap if you can't considering it is all VB code and you should be able to do in WORD what you can in the other 2.

Do these controls just not have properties to be manipulated?

Code:
 Selection.InlineShapes.AddOLEControl ClassType:="Forms.TextBox.1"
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.TypeText Text:="  "
    Selection.InlineShapes.AddOLEControl ClassType:="Forms.TextBox.1"
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Application.Move Left:=242, Top:=24
 
you should be able to do in WORD what you can in the other 2.
Sorry, but where have you been for the last X number of years? That has NEVER been the case. Sure I agree it would be nice but Word VBA has always been sloppy compared to Excel or Access.
So - these controls - made off the developer toolbar - unlike Access or Excel - have NO Name, No identifying information.
Not quite. They have both Title and Tag properties that identify them. Take a look at Greg Maxey's site. Not just the link below, but search through his site for using CC.
Greg Maxey Site

as for legacy formfields, they most certainly DO have identifying information and can be actioned by name or index number.

Gerry
 
Hi Gerry - I have been writing software and databases - I have NEVER had to try to do ANYTHING with VBA in Word. My boss had a thought.... they are scary things.

Thanks for the site info
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top