Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2010
    Posts
    20

    How do I convert an incoming object to binary?

    I need to import PDF and XLS objects and convert them to binary. The following code doesn't work, apparently because the "fd.SelectedItems(1)" is the path of the object instead of the object itself.



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

    If I don't specifically Dim "fileToUpload", when I get to the last line below I get "run time '424' Object required".

    Anyone know the magic words?


    Dim fd As FileDialog
    Dim ImageToBytes() As Byte
    Dim ImageCode As String

    FilePickerControl = False
    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    fd.AllowMultiSelect = False
    If fd.Show = -1 Then
    FileToUpload = fd.SelectedItems(1)
    End If

    ImageToBytes = System.IO.File.ReadAllBytes(FileToUpload)

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    shot in the dark, but try removing "option explicit" if you have it and just
    Dim FileToUpload... not AS anything.

    if that doesnt work, instead of passing FileToUpload, pass fd.SelectedItems(1). outside of that, i dont know.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Convert to ACCDE through VBA
    By johnrt87 in forum Programming
    Replies: 0
    Last Post: 06-28-2010, 07:50 PM
  2. convert txt file
    By anu in forum Programming
    Replies: 1
    Last Post: 04-18-2010, 10:20 AM
  3. Replies: 6
    Last Post: 04-18-2010, 03:41 AM
  4. Convert to MMM/YYYY
    By Brian62 in forum Queries
    Replies: 10
    Last Post: 08-31-2009, 04:54 PM
  5. Replies: 1
    Last Post: 05-20-2009, 09:09 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums