Function FileToString(filePath As String) As String Dim fileNum As Integer Dim fileContent As String Dim fileSize As Long ' Attempt to open the file On Error Resume Next fileNum = Freefile() Open filePath For Binary As fileNum If Err <> 0 Then FileToString = "" ' Return empty string if unable to open the file Exit Function End If On Error Goto 0 ' Determine the size of the file fileSize = Filelen(filePath) ' Read the entire content of the file into a string If fileSize > 0 Then fileContent = Space$(fileSize)+1 ' Create a string buffer of the file size stringlen = Len(fileContent) Get #fileNum, , fileContent Else fileContent = "" ' File is empty or size is zero End If ' Close the file Close fileNum ' Return the file content as a string FileToString = fileContent End Function