Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Dec 2015
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Create text box for every page but it depends...

    What I have is a macro to organize photos based on how many are on each page.
    Now I'm trying to add a text box to each page of pictures. Depending on if there is 1,2 or 3 pictures
    I want the text boxes to be different size/location.
    Also, is there a way to set the default layout option of pictures/textboxes of move with text UNCHECKED?

    Here's what I'm working with:

    The debugger says Canvas Items option is for groups only and I dont know an alternative to accomplish
    CanvasItems.AddTextbox _Orientation:=msoTextOrientationHorizontal,


    Sub Picture()
    Application.ScreenUpdating = False
    Dim i As Long, Rng As Range
    With ActiveDocument
    'While .InlineShapes.Count > 0
    ' .InlineShapes(1).ConvertToShape
    'Wend
    For i = 1 To .ComputeStatistics(wdStatisticPages)
    Set Rng = .GoTo(What:=wdGoToPage, Name:=i)
    Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\page")
    If i = .ComputeStatistics(wdStatisticPages) Then
    Rng.End = .Range.End
    End If

    With Rng
    Select Case .ShapeRange.Count
    Case 1
    With .ShapeRange(1)
    .LockAspectRatio = msoTrue
    .Width = InchesToPoints(5)
    .Left = InchesToPoints(0.55)
    .Top = InchesToPoints(3.13)
    .CanvasItems.AddTextbox _
    Orientation:=msoTextOrientationHorizontal, _
    Left:=0.44, Top:=6.97, Width:=5.18, Height:=0.44
    End With
    Case 2
    With .ShapeRange(1)
    .LockAspectRatio = msoTrue
    .Width = InchesToPoints(5)
    .Left = InchesToPoints(0.55)
    .Top = InchesToPoints(1.55)
    End With
    With .ShapeRange(2)
    .LockAspectRatio = msoTrue
    .Width = InchesToPoints(5)
    .Left = InchesToPoints(0.55)
    .Top = InchesToPoints(5.55)
    .CanvasItems.AddTextbox _
    Orientation:=msoTextOrientationHorizontal, _
    Left:=0.44, Top:=9.3, Width:=5.18, Height:=0.44
    End With
    Case 3
    With .ShapeRange(1)
    .LockAspectRatio = msoTrue
    .Width = InchesToPoints(4.6)
    .Left = InchesToPoints(-0.27)
    .Top = InchesToPoints(0.25)
    End With
    With .ShapeRange(2)
    .LockAspectRatio = msoTrue
    .Width = InchesToPoints(4.6)
    .Left = InchesToPoints(-0.27)
    .Top = InchesToPoints(3.75)
    End With
    With .ShapeRange(3)
    .LockAspectRatio = msoTrue
    .Width = InchesToPoints(4.6)
    .Left = InchesToPoints(-0.27)
    .Top = InchesToPoints(7.25)
    .CanvasItems.AddTextbox _
    Orientation:=msoTextOrientationHorizontal, _
    Left:=4.5, Top:=0.63, Width:=2, Height:=2
    End With
    End Select
    End With
    Next
    End With
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    It would have helped had you said what your ultimate aim was before I wasted time writing code to re-arrange the shapes. The optimal way of doing what you now say you're after is to create suitably-sized tables, with two rows or columns per image, putting the images in one row or column as inlineshapes and using the other for the text.

    PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab at the bottom of this screen.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    New Lounger
    Join Date
    Dec 2015
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Initially, my ultimate goal was just the shape organized and I apologize if you feel you "wasted" your time. I learned a lot about formatting and new functions with that code. This must be a relatively small community because I wasn't intending to bother just one person with all my questions.

    Too bad the macro can't build on itself though, it seems so close? There's more than one way to skin a cat. Thanks for pointing me in the right direction! I'll do some research.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •