Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-04-2018, 06:51 AM
BLUEPUPIL BLUEPUPIL is offline Macro-inserting text box Windows 7 64bit Macro-inserting text box Office 2016
Novice
Macro-inserting text box
 
Join Date: Feb 2016
Posts: 20
BLUEPUPIL is on a distinguished road
Default Macro-inserting text box


Reply With Quote
  #2  
Old 04-04-2018, 06:52 AM
Charles Kenyon Charles Kenyon is offline Macro-inserting text box Windows 10 Macro-inserting text box Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,124
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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)
Reply With Quote
  #3  
Old 04-04-2018, 07:06 AM
BLUEPUPIL BLUEPUPIL is offline Macro-inserting text box Windows 7 64bit Macro-inserting text box Office 2016
Novice
Macro-inserting text box
 
Join Date: Feb 2016
Posts: 20
BLUEPUPIL is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 04-04-2018, 07:56 AM
BLUEPUPIL BLUEPUPIL is offline Macro-inserting text box Windows 7 64bit Macro-inserting text box Office 2016
Novice
Macro-inserting text box
 
Join Date: Feb 2016
Posts: 20
BLUEPUPIL is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
There is a reason why you don't save as a Text Box Building Block?
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*
Reply With Quote
  #5  
Old 04-04-2018, 08:32 AM
Charles Kenyon Charles Kenyon is offline Macro-inserting text box Windows 10 Macro-inserting text box Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,124
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by BLUEPUPIL View Post
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*
Once you insert the TextBox from a Building Block, you can easily move it to where you want it. It will start at the position it was in when you saved it originally as a Building Block.

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.
Reply With Quote
  #6  
Old 04-04-2018, 08:56 AM
Charles Kenyon Charles Kenyon is offline Macro-inserting text box Windows 10 Macro-inserting text box Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,124
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

You can set up a Style using a Frame (although not with any prexisting text).
Frames and Textboxes in Microsoft Word
Reply With Quote
  #7  
Old 04-04-2018, 08:58 AM
Charles Kenyon Charles Kenyon is offline Macro-inserting text box Windows 10 Macro-inserting text box Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,124
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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
Reply With Quote
  #8  
Old 04-04-2018, 01:24 PM
BLUEPUPIL BLUEPUPIL is offline Macro-inserting text box Windows 7 64bit Macro-inserting text box Office 2016
Novice
Macro-inserting text box
 
Join Date: Feb 2016
Posts: 20
BLUEPUPIL is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
Your proposed layout has the text box in front of text. Are you sure that you want to occlude text in your document level?
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.
Reply With Quote
  #9  
Old 04-04-2018, 02:40 PM
BLUEPUPIL BLUEPUPIL is offline Macro-inserting text box Windows 7 64bit Macro-inserting text box Office 2016
Novice
Macro-inserting text box
 
Join Date: Feb 2016
Posts: 20
BLUEPUPIL is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
Once you insert the TextBox from a Building Block, you can easily move it to where you want it. It will start at the position it was in when you saved it originally as a Building Block.
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.
Reply With Quote
  #10  
Old 04-04-2018, 04:28 PM
Charles Kenyon Charles Kenyon is offline Macro-inserting text box Windows 10 Macro-inserting text box Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,124
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

  1. Try, just for fun, creating your text box the way you want in a document.
  2. Select it.
  3. Press Alt+F3
  4. Assign a name. I suggest "_myText"
  5. Put it in the Text Box Gallery
  6. Put it in the Building Blocks.dotx template.
  7. Use the Built-In Category
  8. Press OK.
In a new document, type _myt and press the F3 or Enter key.


Can you work with that?
Reply With Quote
  #11  
Old 04-10-2018, 05:29 AM
Charles Kenyon Charles Kenyon is offline Macro-inserting text box Windows 10 Macro-inserting text box Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,124
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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
You can download a template with this macro in it from my downloads page.
http://www.addbalance.com/word/downl...acroToInsertBB
Reply With Quote
  #12  
Old 04-16-2018, 06:40 AM
BLUEPUPIL BLUEPUPIL is offline Macro-inserting text box Windows 7 64bit Macro-inserting text box Office 2016
Novice
Macro-inserting text box
 
Join Date: Feb 2016
Posts: 20
BLUEPUPIL is on a distinguished road
Default

Reply With Quote
  #13  
Old 04-16-2018, 06:41 AM
BLUEPUPIL BLUEPUPIL is offline Macro-inserting text box Windows 7 64bit Macro-inserting text box Office 2016
Novice
Macro-inserting text box
 
Join Date: Feb 2016
Posts: 20
BLUEPUPIL is on a distinguished road
Default

Reply With Quote
  #14  
Old 04-16-2018, 06:45 AM
BLUEPUPIL BLUEPUPIL is offline Macro-inserting text box Windows 7 64bit Macro-inserting text box Office 2016
Novice
Macro-inserting text box
 
Join Date: Feb 2016
Posts: 20
BLUEPUPIL is on a distinguished road
Default

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
Reply With Quote
  #15  
Old 04-16-2018, 06:59 AM
Charles Kenyon Charles Kenyon is offline Macro-inserting text box Windows 10 Macro-inserting text box Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,124
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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)
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro-inserting text box Macro for inserting and formatting headers and footers Mike_Lennox Word VBA 4 10-06-2016 12:10 AM
Macro-inserting text box Need Macro for Find and Replace, Inserting logo in Ms-Word. Aswinraj Word VBA 1 06-05-2016 04:33 PM
Macro-inserting text box 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
Macro-inserting text box Inserting key strokes with a macro line ACA Word VBA 4 12-03-2012 04:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft