Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Changing File "Summary" Properties Programmatically

hutteto wrote on 1/4/2011 :
Thanks Gary,

Actually I will need to be able to bring in these column names
(Author, Title, Subject, Comments, etc...) into the column header of
an Explorer window.
All the files I will be dealing with here are saved emails and I will
need to update these properties. The purpose is to then go to that
saved directory where all the emails are and be able to sort/filter
the emails based on these properties.
So they will have to be able to be seen in Explorer. Is this what you
mean when you say "viewed in Explorer"?

Thanks


Yes. If you right-click a column header in Explorer you'll see a
dropdown list of optional columns to display. Windows remembers these
for each folder. Optionally, you can set up one folder how you want the
columns to display and then set all folders the same via the option in
the FolderOptions dialog.

What did you think about the FSO solution I posted?

I did some more review of Chip's code and conclude that it was created
for DSO1.4 and not DSO2.0, and so is why it doesn't work. You do know
that when you installed DSO2.0 it put sample code in the Source
subfolder. Unfortunately, you need VB6 to use the demo but you can
still view the code using a text editor. To do this, right-click the
file 'Source\Vb6Demo\FileProp.frm' and open it with Notepad. This demos
how to use DSO2.0 in VB/VBA. Just so you know.., DSO2.0 was released
for use by .Net apps and this is why the DSO1.4 code won't work with
DSO2.0.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Changing File "Summary" Properties Programmatically

Yes I looked at that FSO code but since it wont allow the properties I
set programmatically to b e seen in Explorer, that would not be an
option, since being able to see the properties is the desired result.

I have DSO OLE Document Properties Reader 2.1, so I assume 2.1 is
compatable with 2.0?

Also I checked the files and opened them in text editor, however I
could find no code for reading or writing properties to/from a closed
file.
Can you provide any code?

Thanks
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Changing File "Summary" Properties Programmatically

hutteto wrote on 1/4/2011 :
Yes I looked at that FSO code but since it wont allow the properties I
set programmatically to b e seen in Explorer, that would not be an
option, since being able to see the properties is the desired result.


The Explorer doesn't provide columns for all of the props. I believe
'Keyword' is one of those.

My point about the FSO code is that it reads/writes the streams as
alternate data streams, do demonstrate that this approach does not give
you what you want. (Initially, this is what you asked for)

I don't use FSO much so the code sample may need to be tweaked to work
properly. For example,

Dim fso As Object 'not FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject") 'not New
FileSystemObject

Otherwise, it reads/writes the ADSs just fine.


I have DSO OLE Document Properties Reader 2.1, so I assume 2.1 is
compatable with 2.0?


Sorry, -my bad! The current version IS DSO2.1!

Also I checked the files and opened them in text editor, however I
could find no code for reading or writing properties to/from a closed
file.
Can you provide any code?


That code doesn't physically 'open' any files per se. It just makes
them available to DSO for read/write purposes. All this takes place
under the hood (so to speak). So.., if you send values to a file while
Explorer is open you will see the values appear when Windows updates
Explorer. Same goes when removing/editing. The files, effectively, are
closed during the process in the sense that they can be open[ed] in
another process.

Any method that reads/writes from/to files effectively has to 'open'
them to perform its task. In this sense, the files are 'open' (in
memory) to the DSO process for its intented task. (As opposed to
physically opening the files in an app to read/write their
SummaryProperties)

You only need the code that reads/writes the SummaryProperties.
Examples of that are all there to use in your own procedure. Just sort
through it and pull what you need. My cnc file manager apps don't use
DSO to read because they read from the values embeded in the file
contents. They do, however, write back to the file as well as the
SummaryProperties if the file is stored on a NTFS volume. Essentially,
read/write is left/right oriented so...

gsMyTitle = oSummProps.Title
oSummProps.Title = gsMyTitle
..where gsMyTitle is a global variable

How I use DSO is my apps read/write from/to global variables and use a
function (code follows) to read/write from/to the files. The function
is constructed to write by default since, as I mentioned, I don't use
DSO to read these values.

Code: (watch the word wrap)
=====================================
Function bGetSet_SummaryProps(ByVal Filename As String, Optional
bReadMode As Boolean = False) As Boolean
' The property values used here are global variables set by another
procedure.
' This reads to these variables and writes from them.

Dim m_oDocumentProps As DSOFile.OleDocumentProperties
Dim oSummProps As DSOFile.SummaryProperties
Dim fOpenReadOnly As Boolean

On Error Resume Next
Set m_oDocumentProps = Nothing: Set oSummProps = Nothing
Err.Clear: On Error GoTo ErrExit

Set m_oDocumentProps = New DSOFile.OleDocumentProperties
m_oDocumentProps.Open Filename, fOpenReadOnly,
dsoOptionOpenReadOnlyIfNoWriteAccess

Set oSummProps = m_oDocumentProps.SummaryProperties
With oSummProps
If bReadMode Then 'read from
gsSP_Title = .Title: gsSP_Subject = .Subject: gsSP_Author =
..Author: gsSP_Category = .Category: gsSP_Keywords = .Keywords:
gsSP_Comment = .Comment
Else 'write to
.Title = gsSP_Title: .Subject = gsSP_Subject: .Author =
gsSP_Author: .Category = gsSP_Category: .Keywords = gsSP_Keywords:
..Comment = gsSP_Comment
End If
End With

ErrExit:
bGetSet_SummaryProps = (Err = 0)
'Cleanup...
m_oDocumentProps.Save: m_oDocumentProps.Close
Set m_oDocumentProps = Nothing: Set oSummProps = Nothing
End Function 'bGetSet_SummaryProps()
=====================================

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Changing File "Summary" Properties Programmatically

Oops!
The correct syntax for accessing the Comments prop should be plural
(oSummProps.Comments)

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Changing File "Summary" Properties Programmatically

Gary,

Works perfect! Love the function.
Thank you VERY much.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Changing File "Summary" Properties Programmatically

hutteto submitted this idea :
Gary,

Works perfect! Love the function.
Thank you VERY much.


You're welcome! Glad to help...

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel cells changing to "#VALUE!" whenever another file is opened kk Excel Discussion (Misc queries) 8 March 12th 10 01:58 PM
How do I stop "global" hyperlinks changing to "local" links? Em Excel Worksheet Functions 2 August 26th 08 01:18 PM
Lost "File Menu" - now it's "Edit / View / Insert.." but no "F daves Excel Discussion (Misc queries) 3 April 24th 07 04:52 AM
Scroll Bar missing "Control" tab in "Format Properties" dialog box Peter Rooney Excel Discussion (Misc queries) 5 August 24th 06 05:36 PM
Changing "returned" values from "0" to "blank" LATATC Excel Worksheet Functions 2 October 20th 05 04:41 PM


All times are GMT +1. The time now is 09:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"