#1
|
|||
|
|||
Macro-inserting text box
|
#2
|
|||
|
|||
There is a reason why you don't save as a Text Box Building Block?
Automated Boilerplate Using Microsoft Word (AutoText, AutoCorrect, Building Blocks, and more) |
#3
|
|||
|
|||
The long story short: I'm making attempt to migrate from WordPerfect to MS Word.
In WP I use macros. Because macro recorder in Word don't record properly mouse movements and clicks, I've got some difficulties, for I am not familiar with VBA. For great part of my macros, I've found a bypass- using Styles and assigning shortcut keys. However, I was unable to include in Styles possibilities to highlight text and to insert text boxes. Highlighting text was relatively easy to achieve using macro recorder. And remains one final hurdle- to create a macro which inserts text box with specific text- hence this thread and the need for YOUR HELP. I've made a screen picture to visualize the text box. It's positioned between two horizontal lines and wrap is set to- *in front of text*. The ideal behavior of the macro will be as follows: after putting the blinking cursor somewhere between letters in a word or select a word- execution of the macro will place the text box just above the word in the space between two horizontal lines. I'm assuming that such macro is impossible (I may be wrong), because each time the insertion horizontal point is altered and floats according to the cursor position (vertical position keeps the same value - exact vertical position between two horizontal lines) and came up with compromise- according to macro layout it's possible to determine the vertical position of the text box as *Absolute* and *0.42" below Line* and horizontal as *Relative* and *35% relative to Page*. These figures are taken from # More Layout Options> Layout> Position # of the text box from the picture. I'm bringing here the complete characteristics of the text box, hoping that YOU will help me to organize them in VBA script. ============== 1.Insert a text box between two horizontal lines- The exact position is predetermined or if possible is floating horizontally relative to the cursor position. 2.Text box layout options. 2.1.Position- horizontal- *Relative position- 35% relative to Page*; vertical- *Absolute position- 0.42" below Line*; Options- Move object with text- yes; Allow overlap- yes. 2.2.Text Wrapping- *In front of text*; 2.3.Size- Height- *Absolute-1"* Width- *Absolute-3"* Rotate- *Rotation-0* Scale- Height-100%; Width-100%. 3.Format shape. 3.1.Fill- No fill; 3.2.Line- No line; 4.Font in the text box 4.1.Font- *CollegiateInsideFL*; 4.2.Font size- 30; 4.3.Font color- There are three colors. Each one of the three figures has separate color: First one (10.)-R,G,B= 250,100,0; Second(20.)-R,G,B= 0,176,240; Third(30.)-R,G,B= 146,208,80; 4.4.Text effects- Text Outline- *Solid line*- Color-R,G,B= 0,0,0; Transparency- 0%; Width- 1.5pt. ======================= Last edited by Charles Kenyon; 04-04-2018 at 08:52 AM. Reason: Add paragraph breaks to make more readable. |
#4
|
|||
|
|||
Quick Parts keeps insertion point of the text box away from the desired destination. Maybe, you are pointing to: *Using macros to insert AutoText from a global or document template*
|
#5
|
|||
|
|||
Quote:
Your proposed layout has the text box in front of text. Are you sure that you want to occlude text in your document level? While you can do what you want using a macro, you are reinventing the wheel. Yes, you can use a macro to insert AutoText or another building block. You can also simply attach a keyboard shortcut to the Building Block. Even though it is dated, I strongly recommend that you review Word for Wordperfect Users. Trying to do things in Word the way you would in WP makes things much harder. |
#6
|
|||
|
|||
You can set up a Style using a Frame (although not with any prexisting text).
Frames and Textboxes in Microsoft Word |
#7
|
|||
|
|||
I would recommend a basic understanding of Word's features before you try writing macros or programming. Otherwise, you will be reinventing the wheel.
Here is a good place to start: Basic Concepts of Microsoft Word - from Shauna Kelly |
#8
|
|||
|
|||
I admit, that the request is somewhat strange. But the text box in front of text was tried and tested formula for me. The inconvenience is that I'm obliged to insert the text box by simple copy and paste.
|
#9
|
|||
|
|||
Yes, but its tedious and time consuming to drag a dozen of text boxes on a single page. The whole of my thread is based on the assumption that MS Word is able to insert a text box, wrapped as- *in front of text*, somewhere near the cursor. Am I wrong?
Last edited by BLUEPUPIL; 04-05-2018 at 01:13 AM. |
#10
|
|||
|
|||
Can you work with that? |
#11
|
|||
|
|||
Here is a macro that would insert the textbox formed using the instructions:
It assumes that both the building block and macro are stored in the same template. Code:
Sub InsertMyBB() ' ' Assumes that the Building Block is of the type AutoText (wdTypeAutoText) in Category "General" ' See https://msdn.microsoft.com/en-us/lib...ffice.12).aspx ' ' This is based in part upon contributions from Greg Maxey and Jay Freedman - any errors remain mine ' Written by Charles Kenyon February 2016 ' Dim sBBName As String Dim sTempName As String Dim oBB As BuildingBlock sBBName = "_MyText" 'use the name of your building block instead of "_MyText" sTempName = ThisDocument.FullName ' puts name and full path of template in string variable On Error Resume Next Set oBB = Application.Templates(sTempName).BuildingBlockTypes(wdTypeAutoText) _ .Categories("General").BuildingBlocks(sBBName) If Err.Number = 0 Then oBB.Insert Selection.Range, True Else MsgBox Prompt:="The Building Block '" & sBBName & "' cannot be found in " & _ ThisDocument.Name & ".", Title:="Didn't Work!" End If On Error GoTo 0 lbl_Exit: Exit Sub End Sub http://www.addbalance.com/word/downl...acroToInsertBB |
#12
|
|||
|
|||
|
#13
|
|||
|
|||
|
#14
|
|||
|
|||
1.Draw a text box
2.No Line; No Fill 3.Insert the desired text 4.Tex box wrapping- In front of text 5.Tex box position: A.Horizontal- Absolute position 0" to the right of Character B.Vertical- Absolute position X" below Line 6.Quick Parts- Save selection to Quick Parts Gallery 7.Assign short key Neat and easy thanks to Charles Kenyon |
#15
|
|||
|
|||
Glad to have helped.
Word has a bunch of great features but finding out about them can be tough. AutoText and the other Building Blocks are real gems. Quick Parts is one such Building Block as well as being the generic title/button that Word uses to get to a number of features including fields. Personally, I would save it in the Text Box gallery. Automated Boilerplate Using Microsoft Word (AutoText, AutoCorrect, Building Blocks, and more) |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro for inserting and formatting headers and footers | Mike_Lennox | Word VBA | 4 | 10-06-2016 12:10 AM |
Need Macro for Find and Replace, Inserting logo in Ms-Word. | Aswinraj | Word VBA | 1 | 06-05-2016 04:33 PM |
Inserting and rearranging text by inspecting existing text | rok123 | Word VBA | 9 | 02-05-2016 07:31 PM |
Macro for Inserting Cross-referenced Continuation Headings | rdross51 | Word VBA | 0 | 01-06-2016 10:20 PM |
Inserting key strokes with a macro line | ACA | Word VBA | 4 | 12-03-2012 04:40 AM |