none
Reading a Word Document As A Binary File RRS feed

  • Question

  • Hello:

    This is an unusual question but here it goes.  I want to open a Word document, not using Word, but some application that will read the Word file like "data".  It would expose the Hex characters that make up a word document.  The reason I need to do this is to extract the date from an auto-update date field that opens in Word and replaces the date with TODAY's date.

    Since auto-update date fields don't allow you to see what the previous date was when it was last opened, I need the previous date.  The date field contains the date that a contract was signed, and the developer foolishly made it an auto-update field so that if you open it again, it doesn't show the original date the contract was signed.

    I need a scripting language (i.e. Windows Scripting Host, which according to the forum, has been discontinued because of virus dangers).

    The language must allow me to cycle through a directory of Word files, open each one in hex mode, search the hex data for the date field, and extract the date.  After extracting it, I will write the file name and the date to a text file, close the word document, and then read the next file (similar to the DIR command in VBA).

    Any ideas on a solution?

    Thanks,


    Rich Locus, Logicwurks, LLC

    http://www.logicwurks.com

    Friday, January 24, 2020 4:40 AM

Answers

  • Keep in mind that a .docx / .docm file is actually a zip file, so you may need code that unzips the file, then searches through all its subfolders and files. Many of these files are .xml files that can be manipulated, but I cannot help you with that.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by RichLocus Saturday, January 25, 2020 3:42 AM
    Friday, January 24, 2020 8:50 AM

All replies

  • Keep in mind that a .docx / .docm file is actually a zip file, so you may need code that unzips the file, then searches through all its subfolders and files. Many of these files are .xml files that can be manipulated, but I cannot help you with that.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by RichLocus Saturday, January 25, 2020 3:42 AM
    Friday, January 24, 2020 8:50 AM
  • Hans:

    Thanks.  I forgot about the files being zipped.  I have already written an application that unzips Excel files so you pointed me in the right direction. I didn't realize that Word docs were also zipped.

    Onward and upward :)  I will adapt my Excel code to Word and deal with the directory structures.

    ' ******************************************************************************
    ' Loop Through The Files Just Renamed from BFP to Zip
    ' ******************************************************************************
    strZipFileSelected = Dir(strFolderName & "*.zip")
    
    Do While Len(strZipFileSelected) > 0
    ' ******************************************************************************
    ' Unzip the files into the Export Zip Folder
    ' ******************************************************************************
     oApp.Namespace(ExportZipContentsFolder).CopyHere oApp.Namespace(strFolderName & strZipFileSelected).items
    
    ' ******************************************************************************
    ' Loop through the unzipped files and select only the log files for export
    ' ******************************************************************************
    Set FSO = New FileSystemObject
    Set fils = FSO.GetFolder(ExportZipContentsFolder & "Data\Log\").Files
    
    For Each fil In fils
        strUnzippedFileName = fil.Name
        If Right(strUnzippedFileName, 3) <> "log" Then
            GoTo GetNextFile
        End If
        If Len(strUnzippedFileName) > 14 Then
            GoTo GetNextFile
        End If
        If IsNumeric(Left(strUnzippedFileName, 1)) Then
            FSO.CopyFile fil.Path, fil.ParentFolder.ParentFolder.ParentFolder & "\" & fil.Name
        End If
    GetNextFile:
    Next fil


    Rich Locus, Logicwurks, LLC

    http://www.logicwurks.com

    Saturday, January 25, 2020 3:50 AM