From: Geoff Budd on 4 Mar 2010 07:51 Does anyone know how I can insert a particular type of text box ("Simple Text Box")into a Word 2007 document using a macro (so that I can add it as a button to the Quick Access Toolbar)? It's easy enough to add a button to the Quick Access Toolbar to open up the Text Box Gallery (by using one of the pre-defined customise commands), but I just want to be able to open the "Simple Text Box" with one click, rather than having to select it from the Text Box Gallery every time. Many thanks.
From: Greg Maxey on 4 Mar 2010 08:18 If you mean "Simple Text Box" as defined by the Building Blocks.dotx template then: Sub Macro1() Dim oTmp As Template Dim bExists As Boolean bExists = False Templates.LoadBuildingBlocks For Each oTmp In Templates If oTmp.Name = "Building Blocks.dotx" Then oTmp.BuildingBlockEntries(" Simple Text Box"). _ Insert Where:=Selection.Range, RichText:=True bExists = True Exit For End If Next If Not bExists Then MsgBox "The building block was not found" End Sub If you just a truly simple square textbox then something like this: Sub Macro2() ActiveDocument.Shapes.AddTextbox msoTextOrientationHorizontal, 5, 5, 100, 100 End Sub Geoff Budd wrote: > Does anyone know how I can insert a particular type of text box > ("Simple Text Box")into a Word 2007 document using a macro (so that I > can add it as a button to the Quick Access Toolbar)? > > It's easy enough to add a button to the Quick Access Toolbar to open > up the Text Box Gallery (by using one of the pre-defined customise > commands), but I just want to be able to open the "Simple Text Box" > with one click, rather than having to select it from the Text Box > Gallery every time. > > Many thanks.
From: Geoff Budd on 4 Mar 2010 12:38 Hi Greg, Thanks for this - excellent! Yes, I did mean "Simple Text Box" as defined by Building Blocks.dotx. Just one more thing ... I'm just trying to reduce the total number of mouse clicks to one - i.e. clicking the macro button to insert the text box and then being able to start typing the text straight away. So, is there any way I can leave the focus inside the text box, so that I can start typing text straight away without having to click inside the box first (rather like when you insert a text box from the gallery)?. Many thanks. "Greg Maxey" wrote: > If you mean "Simple Text Box" as defined by the Building Blocks.dotx > template then: > > Sub Macro1() > Dim oTmp As Template > Dim bExists As Boolean > bExists = False > Templates.LoadBuildingBlocks > For Each oTmp In Templates > If oTmp.Name = "Building Blocks.dotx" Then > oTmp.BuildingBlockEntries(" Simple Text Box"). _ > Insert Where:=Selection.Range, RichText:=True > bExists = True > Exit For > End If > Next > If Not bExists Then MsgBox "The building block was not found" > End Sub > > If you just a truly simple square textbox then something like this: > > Sub Macro2() > ActiveDocument.Shapes.AddTextbox msoTextOrientationHorizontal, 5, 5, 100, > 100 > End Sub > > Geoff Budd wrote: > > Does anyone know how I can insert a particular type of text box > > ("Simple Text Box")into a Word 2007 document using a macro (so that I > > can add it as a button to the Quick Access Toolbar)? > > > > It's easy enough to add a button to the Quick Access Toolbar to open > > up the Text Box Gallery (by using one of the pre-defined customise > > commands), but I just want to be able to open the "Simple Text Box" > > with one click, rather than having to select it from the Text Box > > Gallery every time. > > > > Many thanks. > > > . >
From: Greg Maxey on 4 Mar 2010 15:04 Try: Sub ScratchMaco() Dim oShape As Shape Set oShape = ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 200, 200, 200, 100) oShape.TextFrame.TextRange.Text = "[Type a quote from the document or the summary of an " _ & "interesting point. You can position the text box anywhere in the document." _ & " Use the Text Box Tools tab to change the formatting of the pull quote text box.]" oShape.TextFrame.TextRange.Select End Sub "Geoff Budd" <GeoffBudd(a)discussions.microsoft.com> wrote in message news:47B3CF56-5D88-4586-A70C-3FD13A507527(a)microsoft.com... > Hi Greg, > > Thanks for this - excellent! Yes, I did mean "Simple Text Box" as defined > by Building Blocks.dotx. > > Just one more thing ... I'm just trying to reduce the total number of > mouse > clicks to one - i.e. clicking the macro button to insert the text box and > then being able to start typing the text straight away. So, is there any > way > I can leave the focus inside the text box, so that I can start typing text > straight away without having to click inside the box first (rather like > when > you insert a text box from the gallery)?. > > Many thanks. > > "Greg Maxey" wrote: > >> If you mean "Simple Text Box" as defined by the Building Blocks.dotx >> template then: >> >> Sub Macro1() >> Dim oTmp As Template >> Dim bExists As Boolean >> bExists = False >> Templates.LoadBuildingBlocks >> For Each oTmp In Templates >> If oTmp.Name = "Building Blocks.dotx" Then >> oTmp.BuildingBlockEntries(" Simple Text Box"). _ >> Insert Where:=Selection.Range, RichText:=True >> bExists = True >> Exit For >> End If >> Next >> If Not bExists Then MsgBox "The building block was not found" >> End Sub >> >> If you just a truly simple square textbox then something like this: >> >> Sub Macro2() >> ActiveDocument.Shapes.AddTextbox msoTextOrientationHorizontal, 5, 5, 100, >> 100 >> End Sub >> >> Geoff Budd wrote: >> > Does anyone know how I can insert a particular type of text box >> > ("Simple Text Box")into a Word 2007 document using a macro (so that I >> > can add it as a button to the Quick Access Toolbar)? >> > >> > It's easy enough to add a button to the Quick Access Toolbar to open >> > up the Text Box Gallery (by using one of the pre-defined customise >> > commands), but I just want to be able to open the "Simple Text Box" >> > with one click, rather than having to select it from the Text Box >> > Gallery every time. >> > >> > Many thanks. >> >> >> . >>
|
Pages: 1 Prev: Direct edit of Building Blocks Next: Calculate Checkboxes to average total |