excelvbasharepoint

Excel can't find path - Run Time Error 76


I want a userform for Project Tracker Sheet.

I created a userform in Excel and assigned the macro created to one graphic visual.

Code Inside UserForm for save:

Private Sub CommandButton1_Click()
    Dim ws As Worksheet
    Dim i As Integer
    Set ws = Worksheets("Projects")
    Dim lastRow As Long
    lastRow = ws.Cells(ws.Rows.Count, "D").End(xlUp).Row
    Dim textBoxes As Variant
    textBoxes = Array(TextBox1, TextBox2, TextBox3, TextBox4, TextBox5, TextBox6, TextBox7, TextBox8, TextBox9, TextBox10, TextBox11, TextBox12, TextBox13, TextBox14, TextBox15, TextBox16, TextBox17, txtback, txtperson, txtstorage, txtwork, txtaccess, txtdoc, txtdoclink, txtadd)
    For i = 0 To UBound(textBoxes)
        ws.Cells(lastRow + 1, i + 4).Value = textBoxes(i).Value
    Next i
    ' Clear TextBox values
    For i = 0 To UBound(textBoxes)
        textBoxes(i).Value = ""
    Next i
End Sub

Code to Clear Data Entered:

Private Sub CommandButton2_Click()
    Unload Me
    UserForm1.Show
End Sub

Close UserForm:

Private Sub CommandButton3_Click()
    Unload UserForm1
End Sub

Code to open image on initializing:

Private Sub UserForm_Initialize()
    Dim imgPath As String
    imgPath = "C:\Users\Nair.Ha\Downloads\logo.gif"
    Me.Image1.Picture = LoadPicture(imgPath)
    Me.Image1.PictureSizeMode = fmPictureSizeModeStretch ' Adjust the PictureSizeMode as desired
End Sub

Code to open userform:

Sub GraphicClick()
    UserForm1.Show
End Sub

The macro is running in my computer.

I put the macro enabled Excel workbook to SharePoint so my team members can use it.
When they try to open the Excel using option Open Excel in Desktop, they get:

Runtime error 76: Path not found.

I believe the problem is the path is saved in my PC even after uploading the file to SharePoint. I can't find the way to change the path.

Do I need to export the Userform file (.frm) to the same SharePoint site and then try to import it from there?


Solution

  • save logo.gif file next to the excel file and make this change to code

    From

    imgPath = "C:\Users\Nair.Ha\Downloads\logo.gif"
    

    To

    imgPath = ThisWorkbook.Path & "\logo.gif"