-1
我試圖插入一個圖片從一個URL在Excel中的Mac。該網址位於單元格12中,需要轉換網址並將單元格放置在單元格n2中,以此類推1500個單元格。我無法弄清楚如何做到這一點。在Excel中插入一個圖片爲Mac 2016
問題
我試圖插入一個圖片從一個URL在Excel中的Mac。該網址位於單元格12中,需要轉換網址並將單元格放置在單元格n2中,以此類推1500個單元格。我無法弄清楚如何做到這一點。在Excel中插入一個圖片爲Mac 2016
問題
這些選項之一的屏幕截圖應該爲你工作。簡單地改變從C驅動器到你的URL路徑..
Sub InsertPics()
Dim fPath As String, fName As String
Dim r As Range, rng As Range
Application.ScreenUpdating = False
fPath = "C:\Users\Public\Pictures\Sample Pictures\"
Set rng = Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row)
i = 1
For Each r In rng
fName = Dir(fPath)
Do While fName <> ""
If fName = r.Value Then
With ActiveSheet.Pictures.Insert(fPath & fName)
.ShapeRange.LockAspectRatio = msoTrue
Set px = .ShapeRange
If .ShapeRange.Width > Rows(i).Columns(2).Width Then .ShapeRange.Width = Columns(2).Width
With Cells(i, 2)
px.Top = .Top
px.Left = .Left
.RowHeight = px.Height
End With
End With
End If
fName = Dir
Loop
i = i + 1
Next r
Application.ScreenUpdating = True
End Sub
' Note: you need the file extension, such as ',jpg', or whatever you are using, so you can match on that.
Sub Insert()
Dim strFolder As String
Dim strFileName As String
Dim objPic As Picture
Dim rngCell As Range
strFolder = "C:\Users\Public\Pictures\Sample Pictures\" 'change the path accordingly
If Right(strFolder, 1) <> "\" Then
strFolder = strFolder & "\"
End If
Set rngCell = Range("E1") 'starting cell
strFileName = Dir(strFolder & "*.jpg", vbNormal) 'filter for .png files
Do While Len(strFileName) > 0
Set objPic = ActiveSheet.Pictures.Insert(strFolder & strFileName)
With objPic
.Left = rngCell.Left
.Top = rngCell.Top
.Height = rngCell.RowHeight
.Placement = xlMoveAndSize
End With
Set rngCell = rngCell.Offset(1, 0)
strFileName = Dir
Loop
End Sub
嗨,我已經試過這兩種一些在Excel中的VBA模塊的時間和沒有得到它認爲它然後就沒有任何快樂發生。任何想法? – Carl
我完全不熟悉蘋果電腦,但我猜它應該工作。什麼是實際的網址? – ryguy72
嗨。正如上圖所示,具有相同的列和行以及相同的URL。這是我電腦的屏幕截圖。我無法讓它工作 – Carl