Importing graphic links revisited (2025)

Good Day to All,

This was covered in another topic which I raise a few months back but the basics of it was lost in the back and forward suggestions and conversation. So I’m reproducing the facts of the process here to be more easily found by those needing a solution.

Importing and managing graphic images from an external URL has been pretty much the bane of my existence whilst on KNACK. Our database requires many thousands of ID photographs for servicemen from WW2 along with images of Unit badges of identification, memorials etc. In the early days there were issues where knack would export image locations as stored in the database but if you tried to make changes, disaster struck.
No matter what was tried both by myself and knack support, the image line would be corrupted during the import process with leftovers “literal elements” of what was exported or just no appearance of the image.

The problem appeared to be the way the string was exported in native html code like this

< img src=“https://domain-name/photo-archives/Surname-A/ALFORD-QX5456.JPG” />
(without the extra space at start which I removed so you see the text rather than an image)

So you would end up in the database reflecting the broken link symbol like the one above OR
a field value that appeared empty apart from the closing "/>.

THANKFULLY this has been resolved and importing external image links is now relatively easy and trouble free provided you massage what is being input or modified. :nerd_face:

It’s quite easy if you follow the rule GET RID OF THE HTML formatting.
When you importing an external image link you DO NOT need the
< img src= " at the beginning of the item OR the closing " />

A straight text entry https://domain-name/foldername/sub-foldername/imagename.JPG is all that is required.

Most spreadsheet will interpret that line as a hyperlink and there is no problem with that happening. What I would suggest though, particularly if you have a lot of image links, is to verify the validity of the links before importing.

I found a small piece of developer code which does that for you in Excel.

When your sheet is populated, go to DEVELOPER - VISUAL BASIC
Select the SHEET your working on
THEN GOTO - INSERT - MODULE

Now insert the following code then click file save at the top and return to your sheet.

**Public Function CheckURL(url As String)**
**    Dim request As Object**
**    Set request = CreateObject("WinHttp.WinHttpRequest.5.1")**
**    On Error GoTo haveError**
**    With request**
**        .Open "HEAD", url**
**        .Send**
**        CheckURL = .Status**
**    End With**
**    Exit Function**
**haveError:**
**    CheckURL = Err.Description**
**End Function**

save the sheet
(note if you open and close the sheet the code needs to be re-inserted again as it gets disabled at startup due to potential “gremlins” being attached to spreadsheets by nasty little hacker types)

in a new row enter =CHECKURL(CELL NO)

Excel will check the validity of the cell address and if it’s okay return code 200 or error code 404 if it can’t find the item.

Be warned that if you have a lot of images the process takes a little bit of time to complete (there is a % complete shown at the bottom of your page).

But by using this simple bit of code you can eliminate any typos or non-existant links being fed into your database.

The screenshot shows the page couldnt be located returning a 404 error.
The reason was the address should read…images not image…

Once everything is okay, delete the column with the checks in it as unnecessary otherwise you will have an extra line showing errors messages when next you load the spreadsheet.

Hope this little tip might help someone trying to get their head around this problem.

Cheers