View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Li Jianyong Li Jianyong is offline
external usenet poster
 
Posts: 29
Default Problem in Picture alignment

Hello Sirs,

I have programmed following code to insert pictures into my sheet. But I
found there is problem in code line:.Top = atl.Offset(0, 1).Top

My pictures exact position shp.top is bigger than the range
-atl.offset(0,1).top

please check for me and provide help

thanks advancely



Code as below:


Sub insertpic()

Dim shp As Picture


Dim atl As Range

Dim lujing As String

lujing = "G:\Autoline Tensioner"

With Application
.ScreenUpdating = False
.EnableEvents = False
End With



For Each atl In Selection

With atl

.RowHeight = 102.75
With .EntireRow
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End With

atl.Offset(0, 1).ColumnWidth = 22.75

Next

For Each atl In Selection


On Error Resume Next

With atl.Offset(0, 1)

Set shp = .Parent.Pictures.Insert(lujing & "\" & atl.Value & ".jpg")
End With

If Err.Number = 0 Then

With shp

.Left = atl.Offset(0, 1).Left
.Top = atl.Offset(0, 1).Top
.Height = 100
.Width = 133
End With

Else

atl.Offset(0, 1).Value = "No existed picture"
atl.Offset(0, 1).Interior.Color = RGB(255, 0, 0)

End If

On Error GoTo 0




Next

With Application
.ScreenUpdating = True
.EnableEvents = True
End With


End Sub