+ Reply to Thread
Results 1 to 6 of 6

VBA - Inserting, Selecting, Moving Pictures?

Hybrid View

  1. #1
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: VBA - Inserting, Selecting, Moving Pictures?

    Hi, I don't quite understand your error ,but try this.
    Right click your sheet tab. This sheet should have pictures (visible) Inserted from the drawing tool bar.
    Select "View code", VB window appears.
    From the VB Toolbar Select "Insert", "Module". New window appears. Paste the entire code below into the new window.
    Close VB Window.
    Click "Alt+F8" Macro Dialog box appears, Select the code "Pic", Click run fron the Right hand side Menu.
    Pictures in you sheet should be aligned, across & down the sheet.(Hopefully)
    Sub pic()
    Dim oPic As Shape, allpic As String
     Dim oP As String, ac As Integer, c, t
     ActiveSheet.Pictures.Visible = True
      c = 10
      t = 10
      For Each oPic In ActiveSheet.Shapes
       If oPic.Type = 13 Then
            With oPic 'ActiveSheet.Shapes(oPic.Name)
                .Width = 0
                .Height = 50
                .Top = t
                .Left = c
                 c = c + 70
                 If c >= 560 Then t = t + 70
                 c = IIf(c >= 560, 10, c)
        .ScaleHeight 0.75, msoFalse, msoScaleFromTopLeft
        End With
             End If
                  
         Next oPic
    End Sub
    Regards Mick

  2. #2
    Registered User
    Join Date
    04-08-2009
    Location
    New Orleans, LA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: VBA - Inserting, Selecting, Moving Pictures?

    Mick,

    That is great!!! It is working like a charm. One question, what part of the code do I need to change to adjust the resulting size? In other words, the pictures are reduced, which I want, but not quite this small?

    Thanks again, you are a huge help!!!!

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: VBA - Inserting, Selecting, Moving Pictures?

    hi, What you need to do is play with the Variables"c" & "t", as shown below.
    I should change one Variable at a time and then review the result.
    It very much dependent on what you want to achieve.
    Sub Pic()
    Dim oPic As Shape, allpic As String
     Dim oP As String, ac As Integer, c, t
     ActiveSheet.Pictures.Visible = True
      c = 10 ' These are start Borders (Left)
      t = 10 ' These are start Borders (Top)
      For Each oPic In ActiveSheet.Shapes
       If oPic.Type = 13 Then
            With oPic
                .Width = 0
                .Height = 120 '50'(Change Here)
                .Top = t
                .Left = c
                 c = c + 150 '70'(Change Here)
                 
              '(Change "560" Here "Both Lines Below")
                 If c >= 400 Then t = t + 150 '70'(Change Here)
                 c = IIf(c >= 400, 10, c) '560'(Change Here)
    
        .ScaleHeight 0.75, msoFalse, msoScaleFromTopLeft
        End With
             End If
                  
         Next oPic
      End Sub
    Regards Mick

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1