VBA : Change width Column or Height Picture [NOT FIT CELL]

muhammad susanto

Well-known Member
hi all..

this macro code work properly for fit cell, i want to change column width height row in left margin and right margin [not fit cell]
Code:
[COLOR=Navy]Sub[/COLOR][COLOR=#333333] InsertPic()        [/COLOR]    [COLOR=Navy]Dim[/COLOR] I [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long[/COLOR]
    [COLOR=Navy]Dim[/COLOR] xPath [COLOR=Navy]As[/COLOR] [COLOR=Navy]String[/COLOR]
    [COLOR=Navy]Dim[/COLOR] xShape [COLOR=Navy]As[/COLOR] Shape
    [COLOR=Navy]Dim[/COLOR] a  [COLOR=Navy]As[/COLOR] Range
    
    xPath = "L:\test\"
    
    [COLOR=Navy]If[/COLOR] Dir(xPath & "*.jpg") = "" [COLOR=Navy]Then[/COLOR]
        MsgBox "Picture file was not found in path!", vbInformation, "test"
        [COLOR=Navy]Exit[/COLOR] [COLOR=Navy]Sub[/COLOR]
    [COLOR=Navy]End[/COLOR] If
    
    [COLOR=Navy]For[/COLOR] I = 1 To ActiveWorkbook.Sheets.Count
        [COLOR=Navy]Set[/COLOR] a = Sheets(I).Range("H10")
            a.RowHeight = 100
            a.ColumnWidth = 20
            [COLOR=Navy]Set[/COLOR] xShape = Sheets(I).Shapes.AddPicture(xPath & I & ".jpg", True, True, a.Left, a.Top, a.Width, a.Height)
    [COLOR=Navy]Next[/COLOR]
 [COLOR=Navy]End[/COLOR][COLOR=#333333] [/COLOR][COLOR=Navy]Sub[/COLOR]
i attachment with image to easy understand it

thanks in advance...

.sst
 

Some videos you may like

This Week's Hot Topics

Top