 |
|
 |
Is there a way I can examine office document properties (The internal ones such as Author, Comments etc) using a vbscript?
I can't find any reference on the MS VBScript site for any FSO Object that might help
|
|
|
|
 |
|
 |
'VBScript file to get the author and comments
'Tested with Word 2000
Dim strAuthor, strComments
Set objWord = CreateObject("Word.Application") 'Open an instance of Word
'Open an word document and return the "Documents" object
Set objDoc = objWord.Documents.Open("D:\Debug\Test1.doc")
strAuthor = objWord.ActiveDocument.BuiltInDocumentProperties(3) 'wdPropertyAuthor
strComments = objWord.ActiveDocument.BuiltInDocumentProperties(5) 'wdPropertyComments
MsgBox "This document's author is " & strAuthor & vbCrLf &" Comments: " & strComments
'msgbox objWord.Version
'To avoid the "Do you want to save your changes?" dialog box, the script
'sets the Saved property to TRUE before terminating Word.
objDoc.Saved = TRUE
objWord.Quit
=========================
Do not look into FSO because they can only read the binary format of word.
Use COM to access method of word
Refer MSDN for reference
|
|
|
|
 |
|
 |
Very intrigued with the code, however, when running it on a Win2000 system, (logged on user has Admin permissions), the program runs but dies apparently when it hits a "system directory" Error message is:
d:\_script\bertha_index.vbs(58,2) Microsoft VBScript runtime error: Permission denied
The last directory displayed was "System Volume Information" which is a "system directory".
Any suggestions on how to bypass system or hidden directories to preclude this error?
Again, enjoyed the scripts concept, and hope to hear from you in the near future.
Thanks for your time and efforts.
Doug Cranston
|
|
|
|
 |
|
 |
To bypass, you can use the attributes property on the folder object to see if it a system folder or not, and skip as needed.
js
|
|
|
|
 |
|
 |
Thanks for your response...Been a long time.. Will try out your concept, maybe this weekend, if my to do list from my better half lets me.
Have a great day.
Dougc
|
|
|
|
 |
|
 |
It's failing because that folder is only accessible to the SYSTEM user by default. Modify the security settings so that the Administrator has full access rights to the folder, and after applying them, you'll be able to go into that directory as well. This particular issue has caused me a few headaches.
|
|
|
|
 |
|
 |
I have a html-page where i want to display dynamicly all pictures
from a certain directory.
Someone any idea's howto do this
PBA
|
|
|
|
 |
|
 |
Hi
I have a question
How can I do a filesearch using VBScript
say for example if I give c:\test\*.txt
as input it should list all the .txt file
under test directory.
Can anyone help me?
Regards
Gnanave
|
|
|
|
 |
|
 |
Not sure if this might be a supplement to help you, worth a shot. Check out MS (HOWTO: Search Directories to Find or List Files)
I used some of the sample code from this page and tweaked it to build a tool to retrieve all files within a directory (& subs) into an Access database... it was VERY helpful. As it searches (and stores if you like) the files, you can split the extension to retieve only those files. You can also use this to exclude file-types within your search. The code is VB, but i used in Access just to make my life easier to store into a Database. Email me & i'll send you the tool, if you like (Access 97). Good luck.
http://support.microsoft.com/support/kb/articles/Q185/4/76.ASP
|
|
|
|
 |
|
 |
I like it, it is a nice introduction to the use of FileSystemObject with VBScript.
I started playing with the code, here is a small patch:
dim sf, fileColl, line
for each sf in foldcol
spacer = spacer + space(3) + "|"
'wscript.echo spacer + "-- " + sf.name
' If you wanted to show the number of bytes, use these lines instead of above
set fileColl = sf.Files
line = spacer + "-- " + sf.name
if fileColl.Count = 0 then
wscript.echo line + " (empty)"
else
wscript.echo line + _
" (uses " + cstr(FormatNumber(sf.Size, 0)) + " bytes with " + _
cstr(FormatNumber(fileColl.Count, 0)) + " files)"
end if
I believe you should have no problem locating my patch in the source...
Notice the use of '_' to continue a line (I don't know if it well documented), and the use of the Count property to have the number of elements in a collection (I couldn't locate this property in the MSDN doc!).
Of course, you can use the fileColl to list the files or do something on them.
Another trick for newbies like me:
you can run the script by double-clicking on it, of course, but if you want to run it from a command line, you can either type:
start vbscript_prog.vbs (with same result as double-clicking, ie. having each echo in a message box)
wscript vbscript_prog.vbs (idem)
or
cscript /nologo vbscript_prog.vbs (with output on the standard output, so can be redirected to a file)
Try cscript /? for more options.
|
|
|
|
 |