Hi all,
im getting an error when i try to use a cloud folder location as my place to save images in, i can successfully use a local folder on my dektop but it fails when i try to use a url location
im sure im doing soemthing wrong
"X:\WFS\Reporting\Sukh\202401" & newFileName & ".jpg"
thats the local folder but i want it to be a sharepoint folder url like
https://its007149.sharepoint.com/sit...471201286E86E2
thNewNameAndDisplayPath()
' Get the last used row in column AM
Dim lastRow As Long
lastRow = Cells(Rows.Count, "AM").End(xlUp).Row
' Loop through each row in column AM
Dim i As Long
For i = 4 To lastRow ' Assuming data starts from row 4
' Get the image file path from the current row in column AM
Dim imagePath As String
imagePath = Trim(Cells(i, "AM").Value)
' Get the new file name from the current row in column AL
Dim newFileName As String
newFileName = Cells(i, "AL").Value
' Check if the image file path is not empty
If Len(imagePath) > 0 Then
' Check if the file exists using FileSystemObject
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileExists(imagePath) Then
' Build the new file path with the specified name
Dim newFilePath As String
newFilePath = "X:\WFS\Reporting\Sukh\202401" & newFileName & ".jpg" ' Change the path as needed
' Use FileSystemObject for file operations
Dim fs2 As Object
Set fs2 = CreateObject("Scripting.FileSystemObject")
' Check if the destination folder exists; if not, create it
If Not fs2.FolderExists("X:\WFS\Reporting\Sukh\202401") Then
fs2.CreateFolder "X:\WFS\Reporting\Sukh\202401"
End If
' Copy the image to the new file path
fs2.CopyFile imagePath, newFilePath, True
' Display the new file path as a hyperlink in the corresponding row in column AN
Cells(i, "AN").Formula = "=HYPERLINK(""" & newFilePath & """)"
Else
MsgBox "Error: The specified image file does not exist in row " & i & ".", vbExclamation
End If
Else
MsgBox "Error: Please provide a valid image file path in row " & i & ".", vbExclamation
End If
Next i
' Inform the user about the success outside the loop
MsgBox "Images saved successfully.", vbInformation
End Sub"
Appreciate any help on this matter
Many thanks
Bookmarks