PDA

View Full Version : Solved: Cmd Button: In Front of Text



tca_VB
09-26-2008, 12:06 PM
I have a command button that when clicked runs some code...

It worked fine until I worked on trying to position it in the bottom right corner with a full document of text. The goal was also to have it not shown when printing.

So, to accomplish the positioning and no show when print, I read and tried to set the control to In Front of Text.

Using In Front of Text and the following code for FilePrint accomplished the placement and no show when print - BUT - when can no longer click the button to run the code.

**FYI - this button is on a form field template that is form protected, not sure if that helps/hurts. **

Here is the code of the fileprint - again works fine if I use In Front of Text, but then the command button doesn't run it's code on click. It takes me back to the first form field.

Sub FilePrint()
'
' FilePrint Macro

Dim myShape As Shape
With ActiveDocument
For Each myShape In .Shapes
myShape.Visible = msoFalse
Next myShape
End With

ActiveDocument.PrintOut

End Sub


Thanks

tca_VB
09-30-2008, 12:38 PM
I've researched some more and tried other things. Mostly, I have put the command button inside a text box in which the text box has the lines set to none.

This works on some documents/templates, not others. I'm posting one that is not working (simplified doc) to see if someone can figure out why it is occasional and if there is a setting that I'm missing.

Thanks for looking and any help you can provide.

Forms protection is on - but no password. If you open the file from windows explorer you will get a doc1 and can see what I mean that the button doesn't work - puts you back at the first form field. You can open the dot by using open inside of word.

fumei
09-30-2008, 01:11 PM
Very odd. If I unprotect it, then try and protect it again, protection for Forms is greyed out. If I select any formfield, and then try to protect it again, protection for Forms is NOT greyed out.

tca_VB
09-30-2008, 01:26 PM
Yes, I've found that quirk as well. You have to have your cursor in a 'good' place on the document to protect with forms clicked. But you are correct, that's how I have it protected.

Just can't figure out why some work and others don't. I have a 70% failure rate so far working through several docs. No pattern as to what order I'm doing the several steps to put the button on, update code, save protected forms. I'm baffled...

tca_VB
10-01-2008, 11:07 AM
Alright, it's just too quirky. I've been reading on and found another solution that actually works better and cleaner.

Several sites consulted to create a floating toolbar that accesses the code:

http://www.vbaexpress.com/forum/showthread.php?t=22315

http://www.tech-archive.net/Archive/Word/microsoft.public.word.newusers/2007-03/msg00543.html

http://www.vbaexpress.com/forum/showthread.php?t=11142

Thanks to all that viewed and tried to look at it with me. If you are in a similar situation, I suggest you try these alternatives.