• Moving a textbox

    Author
    Topic
    #465684

    Hi

    As part of my template, I provide a macro to add a textbox to the left of the current paragraph/table row/etc to indicate changes in a particular version of the software etc. This macro works perfectly. The problem is that the users would like to run the macro *once* & then just copy or move the textbox to another paragraph etc. Now, what happens is that the textbox disappears when moved to another location/paragraph. For example, move it down verticall & it disappears!. Also, should I consider using frames instead of textboxes although I don’t know much about frames so it may be an irrelevant question.

    Incidently, the template has the page set-up as follows: T= 1, B=1, L=2, R=1 inches. The textbox is to the left of the normal paragraph. See snapshot.

    The macro is as follows:

    Code:
    Sub InsertNewInFlash()
    '
    ' Inserts a new in flash text box
    '
        Dim myTBox As Shape
        Dim curSec As Variant
        
       if ( Selection.Paragraphs(1).Style  ActiveDocument.Styles (wdStyleHeading1) And _
            Selection.Paragraphs(1).Style  ActiveDocument.Styles (wdStyleHeading2) And _
            Selection.Paragraphs(1).Style  ActiveDocument.Styles (wdStyleHeading3) ) Then
            
            StartUndoSaver
            
            ' Switch off screen updates
            Application.ScreenUpdating = False
    
            ' Insert a 'New in v' text box flash to the left of current selection
            Set myTBox = ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _
                                                          InchesToPoints(-1#), _
                                                          InchesToPoints(-0#), _
                                                          45#, _
                                                          25, _
                                                          Selection.Range)
            With myTBox
                .TextFrame.MarginTop = InchesToPoints(0#)
                .TextFrame.MarginLeft = InchesToPoints(0#)
                .TextFrame.MarginRight = InchesToPoints(0#)
                .TextFrame.MarginBottom = InchesToPoints(0#)
          
                .TextFrame.TextRange.ParagraphFormat.Style = FLASHINFO
                .TextFrame.TextRange = "New in v"
            
                .Line.Visible = msoFalse
                .LockAnchor = False
            
                .WrapFormat.Type = 3
                .ZOrder msoBringInFrontOfText
                
                .Select
            End With
            
            Application.ScreenUpdating = True
            
            StopUndoSaver
        End If
    End Sub
    
    Viewing 7 reply threads
    Author
    Replies
    • #1197951

      Hi Robie,

      Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

      Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

      Gary

      • #1197998

        Hi Robie,

        Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

        Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

        Gary

        That’s an interesting thought Gary. There must have been a reason why I am creating it everytime but I can’t remember now. The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

        I will try your Autotext method. Presumeablly, I can move the autotexted textbox once added to a paragraph! Then add a textbox and move it arround, and see whether it disappears or not.

        • #1198164

          The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

          Yes, when setting up the textbox in the user interface, just set it to ‘Move Object with Text’ as well as ‘Lock Anchor’ (both can be accessed by right-clicking on the textbox, in the Format Textbox dialog click on Layout tab, then Advanced button) before you save it as an autotext. When you bring the autotext in later via code, both of these properties will be in effect.

          Gary

        • #1198793

          The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

          Yes, when setting up the textbox in the user interface, just set it to ‘Move Object with Text’ as well as ‘Lock Anchor’ (both can be accessed by right-clicking on the textbox, in the Format Textbox dialog click on Layout tab, then Advanced button) before you save it as an autotext. When you bring the autotext in later via code, both of these properties will be in effect.

          Gary

        • #1199521

          The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

          Yes, when setting up the textbox in the user interface, just set it to ‘Move Object with Text’ as well as ‘Lock Anchor’ (both can be accessed by right-clicking on the textbox, in the Format Textbox dialog click on Layout tab, then Advanced button) before you save it as an autotext. When you bring the autotext in later via code, both of these properties will be in effect.

          Gary

        • #1200408

          The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

          Yes, when setting up the textbox in the user interface, just set it to ‘Move Object with Text’ as well as ‘Lock Anchor’ (both can be accessed by right-clicking on the textbox, in the Format Textbox dialog click on Layout tab, then Advanced button) before you save it as an autotext. When you bring the autotext in later via code, both of these properties will be in effect.

          Gary

        • #1201322

          The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

          Yes, when setting up the textbox in the user interface, just set it to ‘Move Object with Text’ as well as ‘Lock Anchor’ (both can be accessed by right-clicking on the textbox, in the Format Textbox dialog click on Layout tab, then Advanced button) before you save it as an autotext. When you bring the autotext in later via code, both of these properties will be in effect.

          Gary

        • #1202135

          The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

          Yes, when setting up the textbox in the user interface, just set it to ‘Move Object with Text’ as well as ‘Lock Anchor’ (both can be accessed by right-clicking on the textbox, in the Format Textbox dialog click on Layout tab, then Advanced button) before you save it as an autotext. When you bring the autotext in later via code, both of these properties will be in effect.

          Gary

        • #1202847

          The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

          Yes, when setting up the textbox in the user interface, just set it to ‘Move Object with Text’ as well as ‘Lock Anchor’ (both can be accessed by right-clicking on the textbox, in the Format Textbox dialog click on Layout tab, then Advanced button) before you save it as an autotext. When you bring the autotext in later via code, both of these properties will be in effect.

          Gary

        • #1203813

          The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

          Yes, when setting up the textbox in the user interface, just set it to ‘Move Object with Text’ as well as ‘Lock Anchor’ (both can be accessed by right-clicking on the textbox, in the Format Textbox dialog click on Layout tab, then Advanced button) before you save it as an autotext. When you bring the autotext in later via code, both of these properties will be in effect.

          Gary

      • #1198607

        Hi Robie,

        Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

        Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

        Gary

        That’s an interesting thought Gary. There must have been a reason why I am creating it everytime but I can’t remember now. The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

        I will try your Autotext method. Presumeablly, I can move the autotexted textbox once added to a paragraph! Then add a textbox and move it arround, and see whether it disappears or not.

      • #1199015

        Hi Robie,

        Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

        Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

        Gary

        That’s an interesting thought Gary. There must have been a reason why I am creating it everytime but I can’t remember now. The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

        I will try your Autotext method. Presumeablly, I can move the autotexted textbox once added to a paragraph! Then add a textbox and move it arround, and see whether it disappears or not.

      • #1200201

        Hi Robie,

        Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

        Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

        Gary

        That’s an interesting thought Gary. There must have been a reason why I am creating it everytime but I can’t remember now. The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

        I will try your Autotext method. Presumeablly, I can move the autotexted textbox once added to a paragraph! Then add a textbox and move it arround, and see whether it disappears or not.

      • #1200955

        Hi Robie,

        Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

        Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

        Gary

        That’s an interesting thought Gary. There must have been a reason why I am creating it everytime but I can’t remember now. The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

        I will try your Autotext method. Presumeablly, I can move the autotexted textbox once added to a paragraph! Then add a textbox and move it arround, and see whether it disappears or not.

      • #1201914

        Hi Robie,

        Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

        Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

        Gary

        That’s an interesting thought Gary. There must have been a reason why I am creating it everytime but I can’t remember now. The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

        I will try your Autotext method. Presumeablly, I can move the autotexted textbox once added to a paragraph! Then add a textbox and move it arround, and see whether it disappears or not.

      • #1202619

        Hi Robie,

        Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

        Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

        Gary

        That’s an interesting thought Gary. There must have been a reason why I am creating it everytime but I can’t remember now. The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

        I will try your Autotext method. Presumeablly, I can move the autotexted textbox once added to a paragraph! Then add a textbox and move it arround, and see whether it disappears or not.

      • #1203540

        Hi Robie,

        Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

        Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

        Gary

        That’s an interesting thought Gary. There must have been a reason why I am creating it everytime but I can’t remember now. The only thing is that this textbox is locked to the current paragraph and therefore needs to move with it if info is added before that paragraph. Would that be possible with autotexted(is that a new word) textbox?

        I will try your Autotext method. Presumeablly, I can move the autotexted textbox once added to a paragraph! Then add a textbox and move it arround, and see whether it disappears or not.

    • #1198554

      Hi Robie,

      Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

      Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

      Gary

    • #1198863

      Hi Robie,

      Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

      Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

      Gary

    • #1200148

      Hi Robie,

      Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

      Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

      Gary

    • #1200894

      Hi Robie,

      Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

      Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

      Gary

    • #1201820

      Hi Robie,

      Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

      Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

      Gary

    • #1202564

      Hi Robie,

      Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

      Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

      Gary

    • #1203478

      Hi Robie,

      Haven’t had a chance to run your code, but was wondering if you might get a better-behaved textbox if you inserted it as an autotext (that you had previously created manually and saved as an autotext in your template), rather than creating it from scratch each time programatically – anyway, that’s how I insert textboxes, and they seem to behave well.

      Frames are a somewhat deprecated feature and in any case, they are inline with text, which probably wouldn’t work with the kind of layout requirement you have here.

      Gary

    Viewing 7 reply threads
    Reply To: Moving a textbox

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: