How do I convert an incoming object to binary in Access 2007 VBA? -


I have to import PDF and XLS objects and convert them to binary. The following code does not work, apparently because "fd.SelectedItems (1)" is the object's object instead of the object.

If I dim the "fileToUpload" as an object, then I get a "run time" 91 'not set with object variable or block block'.

I do not particularly slow "fileToUpload", when I get to the last line I get the "run time '424' object needed '.

Anyone know that magical word? Dim fd FileDialog dim ImageToBytes () byte dim ImageCode string as FilePickerControl = Fd = Application.FileDialog (msoFileDialogFilePicker) fd.AllowMultiSelect = false as the False set. Show = -1 then FileToUpload = fd.SelectedItems (1) finished then ImageToBytes = System.IO.File.ReadAllBytes (FileToUpload)

What should fileToUpload be? You need to set it as an object, ie, set FileToUpload = fd.SelectedItems (1), but I do not think that thecorrect thing is necessarily fd.SelectedItems, as far as As I can tell (1) is going to return a string value that has a file name / path, not a real file object; I think it should be a string

Maybe it will work:. FileDialog dim strFileToUpload string as dim imageToBytes () byte dim imageCode string as little as fd FilePickerControl = Fd set fd = Application.FileDialog (msoFileDialogFilePicker) fd .allowMultiSelect = False if fd.Show = 1 then strFileToUpload = fd.SelectedItems (1) end if ImageToBytes = System.IO.File.ReadAllBytes (strFileToUpload)


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -