Prev: Is possible to save a .pdf file to Office live with code?
Next: A macro to bold first row in word tables
From: Robin on 19 Jan 2010 11:41 I have a section 1 of a document that contains 2 text boxes: - Text box 1 contains data fields - Text box 2 contains other data fields in a table. I want to toggle text box 2 so I can display or hide it via a macro. But how do I locate that specific text box (2)? I canm easily hode/show all the text boxes in one operation, but I don't want to ever hide text box 1? thanks Robin
From: Greg Maxey on 19 Jan 2010 14:52 Select and Name the textbox: Sub ScratchMaco() Selection.ShapeRange.Name = "TextBoxToBeHidden" End Sub Hide a named shape with code: Sub ScratchMacoII() ActiveDocument.Shapes("TextBoxToBeHidden").Visible = msoFalse End Sub "Robin" <Robin(a)discussions.microsoft.com> wrote in message news:8FA8E386-36D8-4047-936F-0BAA0EBC4374(a)microsoft.com... >I have a section 1 of a document that contains 2 text boxes: > > - Text box 1 contains data fields > - Text box 2 contains other data fields in a table. > > I want to toggle text box 2 so I can display or hide it via a macro. But > how > do I locate that specific text box (2)? I canm easily hode/show all the > text > boxes in one operation, but I don't want to ever hide text box 1? > > thanks > Robin
From: Robin on 20 Jan 2010 00:54 Hi Greg, I thought about doing that, but it measn I have to on-the-fly select and name the text box every time I want to hide it - correct? Then the issue is how do I select just that text box programatically, as I see it I am shifting the problem of getting the correct shape index fpom deletion to selection? I would expect that I could delete the textbox by name if I could name it using the standard Word application interface and not via VBA, but the properties don't allow that (as far as I can see). thanks Robin "Greg Maxey" wrote: > Select and Name the textbox: > Sub ScratchMaco() > Selection.ShapeRange.Name = "TextBoxToBeHidden" > End Sub > > Hide a named shape with code: > > Sub ScratchMacoII() > ActiveDocument.Shapes("TextBoxToBeHidden").Visible = msoFalse > End Sub > > "Robin" <Robin(a)discussions.microsoft.com> wrote in message > news:8FA8E386-36D8-4047-936F-0BAA0EBC4374(a)microsoft.com... > >I have a section 1 of a document that contains 2 text boxes: > > > > - Text box 1 contains data fields > > - Text box 2 contains other data fields in a table. > > > > I want to toggle text box 2 so I can display or hide it via a macro. But > > how > > do I locate that specific text box (2)? I canm easily hode/show all the > > text > > boxes in one operation, but I don't want to ever hide text box 1? > > > > thanks > > Robin > > > . >
From: Greg Maxey on 20 Jan 2010 06:56 Robin, No you would not have to reselect it each time. You would name the textbox shape only once when you create it using the first macro. After it is named you could use the second procedure to set the .visible attribute to the named shape repeatedly <Robin(a)discussions.microsoft.com> wrote in message news:B452A693-5CD6-4FCB-A2C6-4855CA04DAE5(a)microsoft.com... > Hi Greg, > > I thought about doing that, but it measn I have to on-the-fly select and > name the text box every time I want to hide it - correct? Then the issue > is > how do I select just that text box programatically, as I see it I am > shifting > the problem of getting the correct shape index fpom deletion to selection? > I > would expect that I could delete the textbox by name if I could name it > using > the standard Word application interface and not via VBA, but the > properties > don't allow that (as far as I can see). > > thanks > Robin > > > "Greg Maxey" wrote: > >> Select and Name the textbox: >> Sub ScratchMaco() >> Selection.ShapeRange.Name = "TextBoxToBeHidden" >> End Sub >> >> Hide a named shape with code: >> >> Sub ScratchMacoII() >> ActiveDocument.Shapes("TextBoxToBeHidden").Visible = msoFalse >> End Sub >> >> "Robin" <Robin(a)discussions.microsoft.com> wrote in message >> news:8FA8E386-36D8-4047-936F-0BAA0EBC4374(a)microsoft.com... >> >I have a section 1 of a document that contains 2 text boxes: >> > >> > - Text box 1 contains data fields >> > - Text box 2 contains other data fields in a table. >> > >> > I want to toggle text box 2 so I can display or hide it via a macro. >> > But >> > how >> > do I locate that specific text box (2)? I canm easily hode/show all the >> > text >> > boxes in one operation, but I don't want to ever hide text box 1? >> > >> > thanks >> > Robin >> >> >> . >>
From: Robin on 20 Jan 2010 16:50 Greg I think we are looking at it from two different aspects. The text box is inserted into a header via a macro. I have no way of actually selecting this text box to give it a name - it's inserted by the maco but the text box is a via building block itself. It's as if I am in a catch 22 situation. Robin
|
Next
|
Last
Pages: 1 2 Prev: Is possible to save a .pdf file to Office live with code? Next: A macro to bold first row in word tables |