简体   繁体   中英

How to insert an image in an imagebox through path on a server

Hi I'm using thus code to load an image into an image box:

Dim ws As Worksheet, fname As String
Dim p As Object


'~~> Adding a temp sheet
Set ws = ThisWorkbook.Sheets.Add

'~~> Insert the picture in the newly created worksheet
fname = "\\IPADDRESS\folder\fototest\image.jpg"
SavePicture img.Picture, fname
DoEvents
Set p = ws.Pictures.Insert(fname)

the problem is that the image is located on a server that I reach through IP address and excel crashes because it can't reach the address. How can I fix?

Your VBA crashes because of lack of permissions to the target directory. In order to use your SavePicture procedure, first you need read write execute permissions in the remote target directory, and to make sure you have access to this server if it's in a different domain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM