Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 04-13-2012, 12:51 AM
TishyMouse TishyMouse is offline Can't select shapes via macro Windows XP Can't select shapes via macro Office 2007
Novice
Can't select shapes via macro
 
Join Date: Feb 2012
Posts: 22
TishyMouse is on a distinguished road
Default

Thanks for the response Paul. Actually the problem was not the selection, the problem was that the code never even entered the For...Each loop - it didn't pick up the fact that there were shapes in the document at all. It transpires that this is due to the shapes being in a different StoryRange in the document. I finally managed to select the shapes (Text Frames in this case) using the code below. I was able to successfully copy and paste the content of each of the text frames into a separate document. Ideally I would have just liked to remove the text frames in-situ (copying the content into the main body of the document) but I couldn't get this to work.


Code:
Sub SelectShapes()

    Set docSource = ActiveDocument
    Set docTarget = Documents.Add("Normal")

    docSource.Activate

    For Each sr In docSource.StoryRanges
      If sr.StoryType = wdTextFrameStory Then
        sr.Select

         done = False
         While Not done
            sr.Select
         
            Selection.WholeStory
            Selection.Copy
            docTarget.Activate
            Selection.PasteAndFormat (wdPasteDefault)
            docSource.Activate
                        
            Set sr = sr.NextStoryRange
            If sr Is Nothing Then done = True
         Wend
      End If
   Next sr

End Sub
Reply With Quote
 

Tags
shapes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Series Color - Macro judicial85 Excel Programming 0 03-14-2011 02:35 PM
Can't select shapes via macro Where did map shapes go? SueK PowerPoint 1 01-20-2011 04:30 AM
Can't select shapes via macro Find and add new Shapes bonani PowerPoint 1 11-26-2009 06:21 PM
Shapes Will Not Display JoeTx Visio 0 03-13-2008 09:01 AM
My Shapes some appear some don't Jean-Paul Visio 0 03-01-2006 01:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:06 AM.


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