4,375 questions
Help with converting an Excel Macro to Office Script.
David Allison
0
Reputation points
Can anyone help me in converting the below Excel Macro to Office Script?
Sub URLPictureInsert()
Dim theShape As Shape
Dim xRg As Range
Dim xCol As Long
On Error Resume Next
Application.ScreenUpdating = False
Set Rng = ActiveSheet.Range("B5")
For Each cell In Rng
Filename = cell
If InStr(UCase(Filename), "JPG") > 0 Then
ActiveSheet.Pictures.Insert(Filename).Select
Set theShape = Selection.ShapeRange.Item(1)
If theShape Is Nothing Then GoTo isnill
xCol = cell.Column + 1
Set xRg = Cells(cell.Row, xCol)
With theShape
.LockAspectRatio = msoFalse
.Width = 315
.Height = 200
.Top = xRg.Top + (xRg.Height - .Height) / 750
.Left = xRg.Left + (xRg.Width - .Width) / 11
End With
isnill:
Set theShape = Nothing
Range("A2").Select
End If
Next
Application.ScreenUpdating = True
Debug.Print "Done " & Now
Range("B5").ClearContents
End Sub
Microsoft 365 and Office Development Other
Microsoft 365 and Office Install, redeem, activate For business Windows
Sign in to answer