Please, use the next Sub:
Sub SaveByteArray(bArr() As Byte, fileName As String, Optional overWriteFile As Boolean)
With CreateObject("ADODB.Stream")
.Open
.Type = 1
.Write bArr
.SaveToFile fileName, IIf(overWriteFile, 2, 1)
.Close
End With
End Sub
And use it as:
Sub TestSaveByteArray()
Dim fileName As String: fileName = ThisWorkbook.Path & "\myFile.pdf"
Dim fileToRead As String: fileToRead = "C:\your path\TestFile.pdf" 'place the path of an existing pdf file!
Dim arr() As Byte
'load the array (somehow...), only to have a checkable byte array:
arr = ReadBytes(fileToRead) 'you must use your existing array instead!
SaveByteArray arr, fileName, True
End Sub
Private Function ReadBytes(strFile As String) As Byte() 'only to supply a (testing) byte array...
Dim byteArr() As Byte
Dim frFile As Integer: frFile = FreeFile
Open strFile For Binary Access Read As #frFile
ReDim byteArr(0 To LOF(frFile) - 1)
Get #frFile, , byteArr
Close #frFile
ReadBytes = byteArr
End Function