![]() |
Adding and Changing 'CustomDocumentProperties' from VBA on other f
Does anyone know the VBA code to add or change a 'CustomDocumentProperty' in
an Office document at the file level without opening the document? Assume that the VBA code will be running in an Excel workbook. |
Adding and Changing 'CustomDocumentProperties' from VBA on other f
MS provides a DLL to support this. Unfortunately this article has been
updated to reflect .Net, but the DLL should still work from VBA i would think http://support.microsoft.com/default...b;en-us;224351 Here is some information I posted in 1999 =============== Leo, I think you are trying too hard. In Excel97, I went into the VBE and into Tools=References and created a reference to the DSOFile.dll using the browser. Then the following code worked fine: Sub TestDSOFILE() Dim docProp As DSOleFile.DocumentProperties Set docProp = PropertyReader.GetDocumentProperties( _ sFilename:="Y:\docs\Excel_quit.xls") Debug.Print docProp.AppName Debug.Print docProp.Author Debug.Print docProp.Name End Sub It returned the following Microsoft Excel Thomas W. Ogilvy Excel_quit.xls Once you have the reference, you can use the object browser to see what other properties are available. HTH, Tom Ogilvy =============== Of course it needs to be registered with regsvr32 in code Shell "RegSvr32 ""C:\Winnt\system32\DSOFILE.dll"" /s " depending on where you placed the file. if you are willing to open it: http://www.cpearson.com/excel/docprop.htm at Chip Pearson's site. -- Regards, Tom Ogilvy "VBA Dabbler" <VBA wrote in message ... Does anyone know the VBA code to add or change a 'CustomDocumentProperty' in an Office document at the file level without opening the document? Assume that the VBA code will be running in an Excel workbook. |
Adding and Changing 'CustomDocumentProperties' from VBA on oth
Thanks for the reply, Tom.
I've downloaded the DLL - it looks like you have to be in an application development environment, like C++, VB, etc. I'm not sure how this can be used in Visual Basic for Applications (VBA). Am I missing something? Regards, VBA Dabbler "Tom Ogilvy" wrote: MS provides a DLL to support this. Unfortunately this article has been updated to reflect .Net, but the DLL should still work from VBA i would think http://support.microsoft.com/default...b;en-us;224351 Here is some information I posted in 1999 =============== Leo, I think you are trying too hard. In Excel97, I went into the VBE and into Tools=References and created a reference to the DSOFile.dll using the browser. Then the following code worked fine: Sub TestDSOFILE() Dim docProp As DSOleFile.DocumentProperties Set docProp = PropertyReader.GetDocumentProperties( _ sFilename:="Y:\docs\Excel_quit.xls") Debug.Print docProp.AppName Debug.Print docProp.Author Debug.Print docProp.Name End Sub It returned the following Microsoft Excel Thomas W. Ogilvy Excel_quit.xls Once you have the reference, you can use the object browser to see what other properties are available. HTH, Tom Ogilvy =============== Of course it needs to be registered with regsvr32 in code Shell "RegSvr32 ""C:\Winnt\system32\DSOFILE.dll"" /s " depending on where you placed the file. if you are willing to open it: http://www.cpearson.com/excel/docprop.htm at Chip Pearson's site. -- Regards, Tom Ogilvy "VBA Dabbler" <VBA wrote in message ... Does anyone know the VBA code to add or change a 'CustomDocumentProperty' in an Office document at the file level without opening the document? Assume that the VBA code will be running in an Excel workbook. |
Adding and Changing 'CustomDocumentProperties' from VBA on oth
Tom has included some code already, but FYI, the VB files are just text
really, so you can copy/paste into VBA, with a few alterations. NickHK "VBA Dabbler" wrote in message ... Thanks for the reply, Tom. I've downloaded the DLL - it looks like you have to be in an application development environment, like C++, VB, etc. I'm not sure how this can be used in Visual Basic for Applications (VBA). Am I missing something? Regards, VBA Dabbler "Tom Ogilvy" wrote: MS provides a DLL to support this. Unfortunately this article has been updated to reflect .Net, but the DLL should still work from VBA i would think http://support.microsoft.com/default...b;en-us;224351 Here is some information I posted in 1999 =============== Leo, I think you are trying too hard. In Excel97, I went into the VBE and into Tools=References and created a reference to the DSOFile.dll using the browser. Then the following code worked fine: Sub TestDSOFILE() Dim docProp As DSOleFile.DocumentProperties Set docProp = PropertyReader.GetDocumentProperties( _ sFilename:="Y:\docs\Excel_quit.xls") Debug.Print docProp.AppName Debug.Print docProp.Author Debug.Print docProp.Name End Sub It returned the following Microsoft Excel Thomas W. Ogilvy Excel_quit.xls Once you have the reference, you can use the object browser to see what other properties are available. HTH, Tom Ogilvy =============== Of course it needs to be registered with regsvr32 in code Shell "RegSvr32 ""C:\Winnt\system32\DSOFILE.dll"" /s " depending on where you placed the file. if you are willing to open it: http://www.cpearson.com/excel/docprop.htm at Chip Pearson's site. -- Regards, Tom Ogilvy "VBA Dabbler" <VBA wrote in message ... Does anyone know the VBA code to add or change a 'CustomDocumentProperty' in an Office document at the file level without opening the document? Assume that the VBA code will be running in an Excel workbook. |
All times are GMT +1. The time now is 12:25 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com