Excel Macro to insert picture into excel from SharePoint or website !

MAlhash

New Member
Joined
Mar 26, 2023
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Hello everyone!

I was working in a macro where it will insert for me pictures from my C drive, however, I need to exchange the code to insert the same pictures from a workspace or SharePoint or website. I have tried but I was not success. please I need your help.

this is the image address"

"https://itawasol/EN/Workspaces/Hama...ared Documents/Shared Governance/UNATTACH.png"


VBA Code:
Sub Oval28_Click()
    

  Dim c As Range
  Dim picname As String, aCell As String
 
  Application.ScreenUpdating = False
 
  For Each c In Range("AM109:AM112, AM120:AM123, AM131:AM135, AM143:AM146, AM154:AM157,AM165:AM169,AM177:AM180,AM188:AM191,AM199:AM203,AM211:AM214,AM222:AM225,AM233:AM237")
    aCell = c.Address(0, 0)
    Select Case True
      Case IsEmpty(c.Value)
        MsgBox "No value in cell: " & aCell
        Exit Sub
      Case Not IsNumeric(c.Value)
        MsgBox "Value is not numeric in cell: " & aCell
        Exit Sub
      Case c.Value < 1#
        picname = "C:\Users\MAlhashlamoun\Pictures\UNATTACH" & ".png"    ******* here i need to change the picture to sharepoint or website or worspace "https://itawasol/EN/Workspaces/Hamad%20General%20Hospital%20Nursing/Shared%20Documents/Shared%20Governance/UNATTACH.png"
        
      Case c.Value2 >= 1#
        picname = "C:\Users\MAlhashlamoun\Pictures\ATTACH" & ".png"    ******* here i need to change the picture to sharepoint or website "https://itawasol/EN/Workspaces/Hamad%20General%20Hospital%20Nursing/Shared%20Documents/Shared%20Governance/ATTACH.png"
        
        
    End Select
   
    If Dir(picname) = "" Then
      MsgBox "Unable to Find Photo" 'Shows message box if picture not found
      Exit Sub
    End If
   
    'Before inserting the new picture, delete the old one.
    On Error Resume Next
      ActiveSheet.Pictures("name_" & aCell).Delete
    On Error GoTo 0
   
    ActiveSheet.Pictures.Insert(picname).Select
    With Selection
      .Name = "name_" & aCell                  'Name the image with any name.
      .Left = Range("S" & c.Row).Left
      .Top = Range("S" & c.Row).Top
      .ShapeRange.IncrementLeft 32
      .ShapeRange.IncrementTop 5
      .ShapeRange.LockAspectRatio = msoFalse
      .ShapeRange.Height = 20#
      .ShapeRange.Width = 20#
      .ShapeRange.Rotation = 0#
      
    End With
   
  Next
  Call HYPERLINK_Click
  Call HYPER2
  Call HYPER3_Click
  Call Hyper4
  Call Hyper5
  Call Hyper6
  Call Hyper7
  Call Hyper8
  Call Hyper9
  Call Hyper10
  Call Hyper11
  Call Hyper12
  Call Hyper13
  Call Hyper14
  Call Hyper15
  Call Hyper16
  Call Hyper17
  Call Hyper18
  Call Hyper19
  Call Hyper20
  Call Hyper21
  Call Hyper22
  Call Hyper23
  Call Hyper24
  Call Hyper25
  Call Hyper26
  Call Hyper27
  Call Hyper28
  Call Hyper29
  Call Hyper30
  Call Hyper31
  Call Hyper32
  Call Hyper33
  Call Hyper34
  Call Hyper35
  Call Hyper36
  Call Hyper37
  Call Hyper38
  Call Hyper39
  Call Hyper40
  Call Hyper41
  Call Hyper42
  Call Hyper43
  Call Hyper44
  Call Hyper45
  Call Hyper46
  Call Hyper47
  Call Hyper48
  Call Hyper49
  Call Hyper50
  Call Hyper51
  Call Hyper52
  
  
  Application.ScreenUpdating = True
'End Sub

Thank you!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top