Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Previewing a file with a Userform (XL2000 SR1)

    I am trying to create an image on a dialog box that will display a preview of a selected file, similar to the preview panel in the open file dialog box. I think that I need to use an image box to display the image, but how do I get the image of the file? Any help will be appreciated.

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previewing a file with a Userform (XL2000 SR1)

    Use the CopyPicture method.
    Legare Coleman

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previewing a file with a Userform (XL2000 SR1)

    I am not sure what you mean by use the CopyPicture method. Could you provide a few lines of sample code? or elaborate?

    Thanks.

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Previewing a file with a Userform (XL2000 SR1)

    If you are trying to get a picture of a file open dialog box with a certain file selected, go through the motions of selecting the file, and when it is highlighted pres Alt-PrintScreen, launch a bitmap editing program such as Paint or Photo Editor and select edit Paste. You should have a copy of the Dialog box which you can crop and edit as required, save it ( as a jpeg, as it will be more compact) and then you can insert into your userform.

    Does that help ?


    Andrew C

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previewing a file with a Userform (XL2000 SR1)

    Yes, I see what you are saying. But that is not what I am trying to do. I would like to emulate that functionality of the Open File Dialog box. The user will be presented with an interface to navigate to his file and when he selects it, I would like the preview of that particular file to appear on the Userform. The utility that I am building will import an exsisting spreadsheet into my utility, so the file that is selected will always be an .xls file. I just want the user to have a visual of the file that he selected.

    Thanks

  6. #6
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previewing a file with a Userform (XL2000 SR1)

    I am assuming that you want a picture of what the file looks like at the moment to appear, not a picture of the file as it was the day you wrote the code. If so, what you are going to have to do is write code (probably in the change event for the control that the user selects the file) to copy a picture of what you want to display and then paste it into the control. Depending on what control you are using, you might have to put the picture into a file that is loaded by the control. This is not going to be simple in VBA since you don't have things like memory bit maps that you can use for the picture.
    Legare Coleman

  7. #7
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Previewing a file with a Userform (XL2000 SR1)

    You would need additional controls that do not ship with VBA to achieve waht you want. Why not use the built in File Open dialog itself, e.g.<pre> strFilename = Application.GetOpenFilename</pre>

    will return the full path and name of and name of the file selected. It will not actually open it.

    Andrew C

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •