Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PDF FILE TO BINARY STRING FORMAT USING VBA

Status
Not open for further replies.

MSHORT

MIS
Jun 1, 2001
7
US
Does anyone know how or possibly has a code snippet to take a pdf file using the filepath and filename to read into Access VBA code and convert the pdf to a binary string format and assign it to a variable so that it can be appended to an output file as the binary string?

Thanks,
Michael
 
Google ADODB.Stream binary append

Found this frag:

Const adTypeBinary = 1
Set objOStream = CreateObject("ADODB.Stream")
objOStream.Type = adTypeBinary
objOStream.Open

For Each objFile In objRootDir.Files
objOStream.Write ReadByteArray(objFile.Path)
Next

objOStream.Close
objOStream.SaveToFile "OneFile.wmv"

Function ReadByteArray(strFile)
Set objIStream = CreateObject("ADODB.Stream")
With objIStream
.Type = adTypeBinary
.Open
.LoadFromFile strFile
ReadByteArray = .Read
End With
End Function


In a nutshell, you'd create two ADODB.stream objects, load data from file into both and then append to the target stream doing a Stream1.Read()=Stream2.Write,and then save the stream to a file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top