Results 1 to 7 of 7

Insert multiple pictures macro

Threaded View

  1. #1
    Registered User
    Join Date
    06-26-2011
    Location
    Kuopio
    MS-Off Ver
    Excel 2007
    Posts
    18

    Insert multiple pictures macro

    This is the code I'm using to insert multiple pictures in worksheet, problem is that it inserts picture in active cell. I want it to add pictures only at range A50:D65, what do I need to do to make this go right?

    And also, is it possible that pictures are one below another? One picture in row 50, another on row 51 etc. ??

    this is the code;

    Sub InsertPictures() 
         
        Dim Pict() As Variant 
        Dim ImgFileFormat As String 
        Dim PictCell As Range 
        Dim lLoop As Long 
        Dim sShape As Picture 
         
        ActiveSheet.Protect False, False, False, False, False 
        ImgFileFormat = "All Picture Files(*.emf;*.wmf;*.jpg;*.jpeg;*.jfif;*.jpe;*.png;*.bpm;*.gif;*.gfa;*.emz;*.wmz;*.pcz;*.tif;*.tiff;*.cgm;*.eps;*.pct;*.pict;*.wpg;*.pcd;*.pcx;*.cdr;*.fpx;*.mix), *.bmp" 
         
         'Note you can load in any nearly file format
        Pict = Application.GetOpenFilename(ImgFileFormat, MultiSelect:=True) 
        If Not IsArray(Pict) Then 
            Debug.Print "No files selected." 
            Exit Sub 
        End If 
         
        Set PictCell = Selection.Cells(1) 
        For lLoop = LBound(Pict) To UBound(Pict) 
             
            Set sShape = ActiveSheet.Pictures.Insert(Pict(lLoop)) 
             
            With sShape 
                If .Height < 408.75 Then 
                    PictCell.EntireRow.RowHeight = .Height 
                End If 
                 '       If .Width < 254 Then
                 '           PictCell.EntireColumn.ColumnWidth = .Width
                 '       End If
                .Top = PictCell.Top 
                .Left = PictCell.Left 
            End With 
            Set PictCell = PictCell.Offset(1) 
        Next lLoop 
         
    End Sub
    Last edited by Zahhhaaaa; 07-26-2011 at 06:35 AM.

Thread Information

Users Browsing this Thread

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

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