Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-21-2016, 01:37 PM
Chayes Chayes is offline Selecting and moving text boxes identified by specific text. Windows XP Selecting and moving text boxes identified by specific text. Office 2003
Advanced Beginner
Selecting and moving text boxes identified by specific text.
 
Join Date: May 2012
Posts: 76
Chayes is on a distinguished road
Default Selecting and moving text boxes identified by specific text.

Hi All

I wonder if someone can help with a puzzle I have.

On the top of each page of my document , I have a text box which starts with the text "Main Accounts Group :". Each of these text boxes is wrongly positioned to the right of centre on each page.


I need to select and move each of the text boxes containing this text across each page to the left margin so that it is line with other text below.

If anyone can help with some VBA to achieve this , I'd be grateful.




Best Wishes ,







Last edited by Chayes; 02-21-2016 at 04:41 PM.
Reply With Quote
  #2  
Old 02-21-2016, 01:51 PM
macropod's Avatar
macropod macropod is offline Selecting and moving text boxes identified by specific text. Windows 7 64bit Selecting and moving text boxes identified by specific text. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,077
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

If you put one such textbox into the page header and align it as required, you could simply delete the rest.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 02-21-2016, 04:39 PM
Chayes Chayes is offline Selecting and moving text boxes identified by specific text. Windows XP Selecting and moving text boxes identified by specific text. Office 2003
Advanced Beginner
Selecting and moving text boxes identified by specific text.
 
Join Date: May 2012
Posts: 76
Chayes is on a distinguished road
Default

HI

Thanks for getting back.

Yes , I can see that this would work also , but as it can be a big task over many pages I was hoping to automate it via VBA. By hand it would be a large and repetitive task.

Best Wishes ,
Reply With Quote
  #4  
Old 02-21-2016, 04:49 PM
macropod's Avatar
macropod macropod is offline Selecting and moving text boxes identified by specific text. Windows 7 64bit Selecting and moving text boxes identified by specific text. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,077
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Are there other textboxes in the document?
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #5  
Old 02-21-2016, 05:13 PM
Chayes Chayes is offline Selecting and moving text boxes identified by specific text. Windows XP Selecting and moving text boxes identified by specific text. Office 2003
Advanced Beginner
Selecting and moving text boxes identified by specific text.
 
Join Date: May 2012
Posts: 76
Chayes is on a distinguished road
Default

Hi

Yes , there are , so it would need only to operate on those starting with the text "Main Accounts Group :". The text following this phrase can vary

Presently , this is the heading to each page and each sits out-of-place on the mid-right of each page. I'm hoping to be able to move them over to the left and align with the rest of the text below.

I'll attach a sample file so you can see the issue. Ideally , once the VBA is run , the word 'Main' would sit over the word 'Simple' on each page.

Thanks for your help.


Best Wishes ,



Attached Files
File Type: zip Sample.zip (5.2 KB, 1 views)
Reply With Quote
  #6  
Old 02-21-2016, 05:58 PM
macropod's Avatar
macropod macropod is offline Selecting and moving text boxes identified by specific text. Windows 7 64bit Selecting and moving text boxes identified by specific text. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,077
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

It's a good thing you provided the attachment; they're not textboxes but frames. As per my previous advice, you could move one such frame into the page header and delete the rest, but the following code just changes the alignment:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long, sngPos As Single
With ActiveDocument
  For i = 1 To .Frames.Count
    With .Frames(i)
      If .Range.Text Like "*(??? ## - ??? ##)" Then
        sngPos = .HorizontalPosition
        Exit For
      End If
    End With
  Next
  For i = 1 To .Frames.Count
    With .Frames(i)
      If InStr(.Range.Text, "Main Accounts Group :") > 0 Then
        .HorizontalPosition = sngPos
      End If
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #7  
Old 02-21-2016, 06:22 PM
Chayes Chayes is offline Selecting and moving text boxes identified by specific text. Windows XP Selecting and moving text boxes identified by specific text. Office 2003
Advanced Beginner
Selecting and moving text boxes identified by specific text.
 
Join Date: May 2012
Posts: 76
Chayes is on a distinguished road
Exclamation

OK thanks for your help. Much appreciated.

I ran the code and it gives an error unfortunately. This being said , when I dismiss the error box it does seem to have done the job!

At any rate I've attached a zip with the error messages , and hopefully this will help to track down where the issue lies.

Thanks again
Attached Files
File Type: zip Err1.zip (85.8 KB, 1 views)
Reply With Quote
  #8  
Old 02-21-2016, 06:37 PM
macropod's Avatar
macropod macropod is offline Selecting and moving text boxes identified by specific text. Windows 7 64bit Selecting and moving text boxes identified by specific text. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,077
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

That error message makes no sense - it implies there are less frames in the document than it has just counted...
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #9  
Old 02-22-2016, 07:01 AM
Chayes Chayes is offline Selecting and moving text boxes identified by specific text. Windows XP Selecting and moving text boxes identified by specific text. Office 2003
Advanced Beginner
Selecting and moving text boxes identified by specific text.
 
Join Date: May 2012
Posts: 76
Chayes is on a distinguished road
Default

Yes , I see. It's certainly a strange one.

To avoid the message box denoting the error , I tried 'On Error Resume Next' at the top of the code and after a pause it does go on to do the job. I do agree though that it's hard to see why the error should occur.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting and moving text boxes identified by specific text. Editing text in text boxes--please help--driving me crazy! Samantha Jean Word 7 02-09-2017 02:22 AM
how to add text to a document without existing text moving around? Athalwolf Word 7 12-16-2014 05:16 PM
Selecting and moving text boxes identified by specific text. Printing White Text in Blue Text Boxes Rich18144 Word 3 05-29-2014 09:05 AM
Text disappears (but headings and text boxes ok) when printing 1 page of a document msfordummies Word 1 02-21-2013 10:28 PM
Word2010 check boxes and plain text content control boxes in same table fcsungard Word 5 06-01-2012 01:16 AM


All times are GMT -7. The time now is 11:20 AM.


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