showing fileproperties

bender

New Member
Joined
Jan 15, 2003
Messages
7
hi,

Im making a program for school and I want to show the properties of a file in a textbox in visual basic. (like author, title, date and more)

(The documents aren't always the same . Some times there Word documents, Excel documents or something else).
The program I made searches the file on the harddisk and makes a newstring (that I use in the rest of the program) with the file name.

I allready tried several things like

(name).textbox1.value = mynewstring.properties

and things like

(name).textbox1.value = mynewstring.CustomDocumentProperties

and so on

can you tell me how to make it work?

thanks for your time and help.....

Willem van den Pol
the Netherlands
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hello Bender

Are you making a stand alone a Visual Basic Applciation to carry out the task you require or simply calling the code from within a an office document?

you seem to suggest you are using a VB exe (correct me if im wrong). If you are im not too sure how this code will work and im not too sure how you would go about opening up each file you require to read the properties from. I guessing you would have to open the file first. I again assume you will be using the common dialogue open control. You would have to remember to add the appropriate references to the project tho first (you can the references and their filepaths from the object browser).

The code in my example uses the ThisWorkbook class to call the properties that you require from within excel. So although it does what you require from within Excel it will not work in other office applciations such as Access.

the function
Code:
Function ReadProperty(PropertyName As String) As Variant

PropertyName = ThisWorkbook.BuiltinDocumentProperties(PropertyName).Value
ReadProperty = PropertyName

End Function

You can then call the function from wherever required using similar code to the following.

Code:
TextBox1.Value = ReadProperty("Last Save Time")

you can replace the "Last Save Time" with which ever property you require such as "Last Saved By"", "Title", "Subject" Etc. Im not too sure either which are and are not available. Most i have tested are although some were not.

If you subsitute the ThisWorkbook for ThisDocument the code will also work in word. I dont really have any clue on how to do this for access or power point etc. Try a search for Reading Access Properties.

You mentioned that you have a string (newString) that is genereted from a file name. You could simply select the relevant code using this generted string say call the code to read the Excel documents when the file path is *.xls etc.

Anyway i hope i have been of some Help

Chris
 
Upvote 0

Forum statistics

Threads
1,221,692
Messages
6,161,334
Members
451,697
Latest member
pedroDH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top