• Previewing a file with a Userform (XL2000 SR1)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Previewing a file with a Userform (XL2000 SR1)

    Author
    Topic
    #359393

    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.

    Viewing 2 reply threads
    Author
    Replies
    • #538567

      Use the CopyPicture method.

    • #538569

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

      Thanks.

      • #538576

        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

        • #538583

          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.

        • #538605

          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.

                strFilename = Application.GetOpenFilename

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

          Andrew C

    • #538574

      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

    Viewing 2 reply threads
    Reply To: Reply #538574 in Previewing a file with a Userform (XL2000 SR1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel