use listbox to show metadata from selected document

  • Hi all,


    I have a macro that list all the files in a folder in a listbox. The idea would be that when I select a file from the folder, it will show the metadata in a listbox.
    I found a macro that list the metadata from a file name and path in a folder, but I would like to combine it so when I click on the file from the listbox, it shows on the second listbox.


    This is the code I have so far:


    Extract metadata:



    Code for the file lister:



    Greetings.

  • Re: use listbox to show metadata from selected document


    Hi Pike,
    Can I change so it also opens the word documents?
    In the first test it was freezing when choosing the folder.


    Greetings.

  • Re: use listbox to show metadata from selected document


    Hi Pike,


    It works, just missed that out to keep the file out of the same folder :)
    If I would like to modify it to show the metadata from a word doc, I could just put there to look for word documents? and if so, how to add the change?


    Greetings.

  • Re: use listbox to show metadata from selected document


  • Re: use listbox to show metadata from selected document


    Hi Pike,


    I could not answer earlier as I was out for a long weekend.
    I just did check it, and it works great. There is only one strange thing. some documents it wants to open, and some of them shows the metadata. I get the trouble line here:


    Code
    Set objDoc = objWord.Documents.Open(FilePath & .ListBox1.List(i))


    Any idea how this occurs?
    My next step is to show the document in a web browser window on the form it self. I already made this work with buttons with links, but now I will try to pass the file selected also to the web browser.
    I guess it can have a double function. It shows the metadata in the listbox and the document (word document or excel document in the viewer).


    Big thanks for your great code.


    Greetings.

  • Re: use listbox to show metadata from selected document


    Hi Pike,


    One more question, is it also possible to have the metadata for excel, pdf and word? this way if I click on one excel file, it will show the metadata for excel, if for PDF, then the pdf metadata and if word, the word metadata.
    If it can be combined to show the document and metadata, that would be a great solution.



    Greetings.

  • Re: use listbox to show metadata from selected document


    Hi Pike,


    How can I pass the value from the select file in the ListBox1 to the WebBrowser1. I would like to add this to the code that you provided in post #8 above these lines.


    In one of my previous macro in a userform I used in a buton:

    Code
    WebBrowser1.Navigate "C:\Temp_Notes\Notes1.doc"


    It seems that when I click one file in the ListBox1 it will appear in ListBox2, but when I clicked for a second time, it wants to open it instead of showing only the metadata.


    Greetings.

  • Re: use listbox to show metadata from selected document


    try

  • Re: use listbox to show metadata from selected document


    Hi Pike,


    I did the same as above lines for PDF files to show up in the web browser control, put it got frozen. Do you have any clue why this happens? it works fine with excel and word documents, but PDF will just freeze.


    I was thinking that maybe I could just show up only excel and word documents and avoid others if they not meet the criteria.


    I just need to figure out how to pass to the web browser control the file that I have selected on the listbox1. Does it have to be on double click only?


    Greetings.

  • Re: use listbox to show metadata from selected document


    Hi,
    This works for me
    The whole userform code

  • Re: use listbox to show metadata from selected document


    Hi Pike,


    Big thanks for the above code.
    It would be great to pass the selected file to the WebBrowser1. Any idea how to get that part working? I already inlcuded the WebBrowser1 in the userform.


    Greetings.

  • Re: use listbox to show metadata from selected document


    Hi Pike,
    I use the web browser control to view the word and excel documents in the user form. In a previous macro, I had buttons that had code to the address of the file

    Code
    WebBrowser1.Navigate "C:\Temp_Notes\Notes1.doc"


    When I click on one of the buttons, the word or excel file will open in the browser control and I can view the documents without opening them.
    The whole setup is to have kind of a DAM application to find easier my file.


    Greetings.

  • Re: use listbox to show metadata from selected document


    Hi Pike,


    I tried your code and it worked. The only problem I have is when I select an excel file and then I select a word file. I get the following error: run-time error "1004' Method 'DisplayAlerts' of object'_'Application' failed


    I placed the code in this part:


    No clue if I did wrong.


    You where asking above the full code, maybe I don't understand the question, but if it is about the code for the web browser control, it was only that small line above on the button it self in the user form.


    Greetings.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!