how would i do this - put the name of document and its statics into an excel file

how would i go about rather it is powershell, vbscript, autoit (i don't have a compiler for c++ or any language like that)

i'm wanting to parse the file>properties>advanced properties then characters with spaces count into a spreadsheet

so its something like this
title                                  count
jan23-2016                     5412

can it be done with powershell? if so how?
or any other scripting language?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

With the Document open or closed?

I'd use VBA for this.

What is the trigger for adding to / updating the spreadsheet?

How many documents? How many people are involved in this?
bbimisAuthor Commented:
Well I'm wanting to take all documents on desktop and read the filename,  then the statistics ad stated above into an excel file.  Basically to make an invoice for transcription. . So once they are parsed then the document is moved to a complete folder.  I just haven't a clue how to do it and what scripting language to use.
Bill PrewIT / Software Engineering ConsultantCommented:
Sure, this is doable in a VBScript approach.

What columns do you want in the output file?  I would suggest creating it as a comma delimited file, which can then easily be opened in Excel.

I assume Word will be installed on the computer you need to do this on?

Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Bill PrewIT / Software Engineering ConsultantCommented:
And where would you like the output file written to?

Bill PrewIT / Software Engineering ConsultantCommented:
Okay, here is a good starting scipt for you.  It's written in VBS, so runs standalone, but does require Word to be installed on the machine running the script.  Save this as a VBS file, and then run from a command line (or BAT file) as follows:

cscript EE28923283.vbs

Output currently goes to a file named "docstats.csv" in the current folder when the script is run, but you can adjust that in the code if desired.  It processes all files on the users Desktop that match the extensions specified in the script.  These are currently set to .DOC and .DOCX but you can adjust if needed.  They have to be WORD files though.

Give a test and let me know if you have questions or I misunderstood something.

' Define needed I/O constants
Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2

' Define constans needed for Word data gathering
Const wdPropertyTitle = 1
Const wdStatisticWords = 0 'Count of words
Const wdStatisticLines = 1 'Count of lines
Const wdStatisticPages = 2 'Count of pages
Const wdStatisticCharacters = 3 'Count of characters
Const wdStatisticParagraphs = 4 'Count of paragraphs
Const wdStatisticCharactersWithSpaces = 5 'Count of characters including spaces
Const wdStatisticFarEastCharacters = 6 'Count of characters for Asian languages

' Create needed objects
Set objShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Define folders and files to work with
strBaseDir = objShell.SpecialFolders("Desktop")
arrExts = Array(".doc", ".docx")
strOutFile = "docstats.csv"

' Invoke Word, but don't show it
Set objWord = CreateObject("Word.Application")
objWord.Visible = False

' Open output file, write header line
Set objOutFile = objFSO.OpenTextFile(strOutFile, ForWriting, True)
objOutFile.WriteLine Quote("File") & "," & Quote("Title") & "," & Quote("Count")
' Load Word
Set objWord = CreateObject("Word.Application")

' Access the folder of files to process
Set objFolder = objFSO.GetFolder(strBaseDir)

' Process each file in the folder
For Each objFile in objFolder.Files

   ' See if the extension matches the ones we want to scan
   blnMatch = False
   For Each strExt in arrExts
      If LCase(Right(objFile.Name, Len(strExt))) = LCase(strExt) Then
         blnMatch = True
         Exit For
      End If

   If blnMatch Then
      On Error Resume Next

      ' Open this file in Word, catch any errors in case we hit a bad file
      Set objDoc = objWord.Documents.Open(objFile.Path)
      If Err.Number = 0 Then
         ' Write file info to output file
         objOutFile.WriteLine Quote(objFile.Name) & "," & Quote(objDoc.BuiltInDocumentProperties(wdPropertyTitle)) & "," & objDoc.ComputeStatistics(wdStatisticCharactersWithSpaces)

         ' Close document
         objOutFile.WriteLine Quote(objFile.Name) & "," & Quote("*** ERROR READING FILE ***") & ",0"
      End If

      On Error Goto 0
   End If

' Close Word and output file

' Add surrounding double quotes to a string
Function Quote(s)
   Quote = Chr(34) & s & Chr(34)
End Function

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bbimisAuthor Commented:
wow, this will do the trick. You happen to know any good books to learn vbscript  or online resources?
Bill PrewIT / Software Engineering ConsultantCommented:
I do have a few links and will share them with you shortly, headed out just now...

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.