AL_XResearch
asked on
Setting a file's attributes without using Dsofile.dll
I am creating a system in Excel VBA for multiple users for which I need to set the extended attributes for a a file (e.g. the 'Comments' property of TIF, PDF files)
How can I do this with VBA ? Is there an API command I can use ?
All my searches of the Internet have found nothing except DSOFile.dll - which I do not want to use as this would require an install for each user of my system.
I have searched on Experts Exchange and have likewise found no other suggestions that DSOFile.dll.
There is FileSetAttr but this only sets the flags such as 'ReadOnly' and 'Archive'.
Any suggestions would be most appreciated.
How can I do this with VBA ? Is there an API command I can use ?
All my searches of the Internet have found nothing except DSOFile.dll - which I do not want to use as this would require an install for each user of my system.
I have searched on Experts Exchange and have likewise found no other suggestions that DSOFile.dll.
There is FileSetAttr but this only sets the flags such as 'ReadOnly' and 'Archive'.
Any suggestions would be most appreciated.
ASKER
Thanks richardburwood, however we don't want to install any other software and are using Adobe Distiller.
Really since you can right-click and set the properties of non-Office files in Windows UI there must be an equivilant API function.
You can use the 'Microsoft Shell Controls And Automation' command [.GetDetailsOf] to read attributes from ANY file but there is no corrisponding set command.
Really since you can right-click and set the properties of non-Office files in Windows UI there must be an equivilant API function.
You can use the 'Microsoft Shell Controls And Automation' command [.GetDetailsOf] to read attributes from ANY file but there is no corrisponding set command.
ASKER
My requirements have now changed in that we need to set these attributes on any file type that supports them - not just PDFs.
ASKER
Does anyone have any other suggestions ?
ASKER
I am sorry of this has caused an issue, but I am waiting to see if there will be any further contributors to this question. How can I either re-publise this question to alert all users to an outstanding question or close the question as un-resolved ?
Thanks
Thanks
Found this on the Microsoft site:
http://msdn.microsoft.com/en-us/library/aa164486(v=office.10).aspx
http://msdn.microsoft.com/en-us/library/aa164486(v=office.10).aspx
Just found this:
http://www.codeproject.com/KB/files/SummInfoPropSetFile.aspx
Which may be helpfull to point you in the right direction, but it is in C++
JimD.
http://www.codeproject.com/KB/files/SummInfoPropSetFile.aspx
Which may be helpfull to point you in the right direction, but it is in C++
JimD.
Well here's some code in VBA for setting a revision number on an Excel spreadsheet, so this is along the right lines:
http://us.generation-nt.com/how-do-i-retrieve-entire-revision-number-excel-2007-help-144990531.html
Might take a little bit of work to figure it out, but it should be doable between the two links I posted.
JimD.
http://us.generation-nt.com/how-do-i-retrieve-entire-revision-number-excel-2007-help-144990531.html
Might take a little bit of work to figure it out, but it should be doable between the two links I posted.
JimD.
see if this link to win api for file management helps:
http://msdn.microsoft.com/en-us/library/aa364232(v=VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa364232(v=VS.85).aspx
see also (sample code):
http://www.ask-4it.com/how-to-use-findfirstfile-win32-api-from-visual-basic-code-2-ca.html
http://www.ask-4it.com/how-to-use-findfirstfile-win32-api-from-visual-basic-code-2-ca.html
ASKER
Thank you 'fyed' for your repsonse. Unfortuantly the FileSystemObject is only capable of setting the 'Read Only', 'Hidden' and 'Archive' type attributes of a file. I need to be able to set the summary properties of a file such as 'Comments', 'Author' and 'keywords'.
So far all I can see without amending the target file at the binary level the only methid is the DSOFile.dll solution.
So far all I can see without amending the target file at the binary level the only methid is the DSOFile.dll solution.
ASKER
Thank you 'puppydogbuddyDate' for you post today @ 3:41 but unfortunatly these API functions are only capable of modifying standard file attributes such as 'Read Only', 'Hidden' and 'Archive'.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you 'robberbaron' - unfortunately there is no possibility of developing an application in Deplhi, I don't know the language and one of the pre-requisites of this system development is a zero install requirement (which makes system development in Excel ideal). Although DSOFile.dl will need to be registered on all user's PC this is the limit of per-user customisation I am afraid.
1/ zero -install.... I have used a small app stored and executed from a shared drive so no user install needed.
2/ yes, i had to get a friend to compile my delphi app for me. but it is very simple.
3/ if you can get DSOfile installed, that will work. There is no way within Excel VBA to write direct to the SummaryProperties stream. needs C++ (ie dsofile) or Delphi.
4/ there are 64bit versions of DSOFile available but you probably dont need them from VBA (i think it is always 32bit)
2/ yes, i had to get a friend to compile my delphi app for me. but it is very simple.
3/ if you can get DSOfile installed, that will work. There is no way within Excel VBA to write direct to the SummaryProperties stream. needs C++ (ie dsofile) or Delphi.
4/ there are 64bit versions of DSOFile available but you probably dont need them from VBA (i think it is always 32bit)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<<I was hoping that there was an API way in which to modify the summary details - but it does not appear so. I will have to stick to using DSOFile.dll. >>
?? The links I posted has code only using oleaut32...
JimD.
?? The links I posted has code only using oleaut32...
JimD.
ASKER
Hi 'JDettman' - thank you for your contributions. Yes I did look at the link you posted but a) it appears too complicated for this task b) nearly all the reference material for 'StgOpenStorageEx' is written for C or it's variants (which it would take too long to translate) and c) as this uses OLE I would say that it is basically the same as Micorosoft's DSOFile.dll except that it is low level, would require more work / testing and does not provide such a clean interface / set of commands for accessing a file's properties.
Indeed the following artical on this site also reaches the same conclusion as I have; that DSOFile.dll is really the only viable VB alterantive.
http://www.experts-exchang e.com/Prog ramming/La nguages/Vi sual_Basic /Q_2055522 8.html
I will certainly keep your link in mind though for the future.
Thanks again.
Indeed the following artical on this site also reaches the same conclusion as I have; that DSOFile.dll is really the only viable VB alterantive.
http://www.experts-exchang
I will certainly keep your link in mind though for the future.
Thanks again.
With respect,
<<a) it appears too complicated for this task >>
It's not my fault that what you asked for is complicated.
<<b) nearly all the reference material for 'StgOpenStorageEx' is written for C or it's variants (which it would take too long to translate)>>
The second link is in VBA and shows setting the revsion property on an Excel file.
<< c) as this uses OLE I would say that it is basically the same as Micorosoft's DSOFile.dll except that it is low level, would require more work / testing and does not provide such a clean interface / set of commands for accessing a file's properties. >>
Same maybe, but you asked for a method that uses something other then DSOFile.dll, which is what I found. Again, it's not my fault that what your attempting to do needs a low level solution and is more complicated as a result.
I'm not asking that this question be closed differently, but please keep in mind that when you ask a question in the future, it's not the fault of the expert if you don't like the solution.
JimD.
<<a) it appears too complicated for this task >>
It's not my fault that what you asked for is complicated.
<<b) nearly all the reference material for 'StgOpenStorageEx' is written for C or it's variants (which it would take too long to translate)>>
The second link is in VBA and shows setting the revsion property on an Excel file.
<< c) as this uses OLE I would say that it is basically the same as Micorosoft's DSOFile.dll except that it is low level, would require more work / testing and does not provide such a clean interface / set of commands for accessing a file's properties. >>
Same maybe, but you asked for a method that uses something other then DSOFile.dll, which is what I found. Again, it's not my fault that what your attempting to do needs a low level solution and is more complicated as a result.
I'm not asking that this question be closed differently, but please keep in mind that when you ask a question in the future, it's not the fault of the expert if you don't like the solution.
JimD.
that Excel workbook method posted by JDettman works well. uses Ole32 & other win apis.
note that the other PropertyId values are found at http://207.46.16.248/en-us/library/dd942089%28PROT.13%29.aspx
PIDSI_COMMENTS = &H6
i have changed the code to successfully write the subject data. could easyly be moded to write a listed parameter.
I will be looking at it further for my own use, but i currently use UserProperties via dso so dont know if this method works for those.
note that the other PropertyId values are found at http://207.46.16.248/en-us/library/dd942089%28PROT.13%29.aspx
PIDSI_COMMENTS = &H6
i have changed the code to successfully write the subject data. could easyly be moded to write a listed parameter.
I will be looking at it further for my own use, but i currently use UserProperties via dso so dont know if this method works for those.
ASKER
JDettman : I apologise if you took my previous post the wrong way. I was not implying that it was your fault it was complicated or that the links you supplied were not useful. It is just that for this solution I don't have the time for developing & testing complex code and since I am not familiar with those functions I would not be confident releasing such a solution until I have thoroughly understood, tested and researched that method.
I have to admit that I didn't initially see that the VBA revision number updating code used the same function as the C++ code. My apologies for that.
As I said in my earlier post today, although I was hoping for a relatively straight forward API call with no install, I will use the DSOFile approach. Additionally my comment about the OLE code and DSOFile appearing functionally the same was not meant as a criticism - just a observation that if Microsoft have taken the time to develop and test a solution to simplify this task, that presumably uses the same techniques as your link, then it would seem counterproductive for me to invest the time to reproduce their work and make the code more complicated.
I would never imply that an expert was at fault for suggesting a complex solution, all solutions are valuable and there are very few solutions that are not complex.
Once again I am sorry for any misunderstanding.
I have to admit that I didn't initially see that the VBA revision number updating code used the same function as the C++ code. My apologies for that.
As I said in my earlier post today, although I was hoping for a relatively straight forward API call with no install, I will use the DSOFile approach. Additionally my comment about the OLE code and DSOFile appearing functionally the same was not meant as a criticism - just a observation that if Microsoft have taken the time to develop and test a solution to simplify this task, that presumably uses the same techniques as your link, then it would seem counterproductive for me to invest the time to reproduce their work and make the code more complicated.
I would never imply that an expert was at fault for suggesting a complex solution, all solutions are valuable and there are very few solutions that are not complex.
Once again I am sorry for any misunderstanding.
<<Once again I am sorry for any misunderstanding.>>
No problem here. I was just pointing some things that might be helpful down the road with other questions.
JimD.
No problem here. I was just pointing some things that might be helpful down the road with other questions.
JimD.
ASKER
Although the solution from 'robberbaron' is interesting it does not solve my issue.
See code below to get metadata using Cute PDF from a PDF file.
Open in new window