none
word docs saved with doc extantion RRS feed

  • Question

  • Hello ,

    Word 2010 is really hard to digest

    I've got an office with mixed environment word XP,2003,2007,2010.

    For the convenience all 2007, 2010 words set to save documents in doc format. Once in a wile I've got situation were docx document actually receives doc extension and then the hell break loose :-).

    This documents crashing word 2010 on normal.dotm error. Word 2007 opens them with no problem, word 2003 can't open them even if the convertor installed...

    Working environment is vba application that uses the same code for all platforms

        Set wordobj = GetObject(, "Word.Application")

            If Err.number <> 0 Then

                WordWasOpen = False

                Set wordobj = CreateObject("Word.Application")

            Else

            WordWasOpen = True

        End If

        Err.Clear

    .

    .

    .

        With wordobj

                .visible = True

    .Documents.Open (full_pass)

    End With

    wordobj.Activate

     

    Any help will be appreciated

     

    Leon

     

    Monday, January 2, 2012 6:31 PM

Answers

  • Somebody is doing something wrong if you have docx format documents with doc extensions - Word does not do this itself - but both Word 2007 and Word 2010 will open them, so something else is causing your crash.
     
    However, in addition to what Cindy has said, if all you want to do is check if a file is old or new format, you don't need to go to the lengths described in the linked articles; you can just look at the file signature.
     
        Dim FileName    As String
        Dim FileNum     As Long
       
        Dim Signature   As Long
        
        FileName = "C:\Path\To\Document.doc"
        FileNum = FreeFile
        Open FileName For Binary Access Read As FileNum
        Get FileNum, , Signature
        Close FileNum
       
        Select Case Signature
            Case &H4034B50
                ' File is a Zip Archive - assume docx/docm file
            Case &HE011CFD0
                ' File is a Compound Binary File - assume doc file
            Case Else
                ' File is not a Document
        End Select

       

    Enjoy,
    Tony
    www.WordArticles.com
    • Marked as answer by Masig Wednesday, January 4, 2012 2:38 PM
    Tuesday, January 3, 2012 5:36 PM

All replies

  • Hello,

     

    From what I know, Word 2003 cannot save/open docx documents. Try to determine when the save to doc is made using a log system if yo have no other way.

    Once you find the scenarios, a cause-solution situation can be made.

     

    PS: Docx to Doc means the loss of all the data stored in XML, and all the extensions that were added in office 2007 or above (like ContentControls).

     

    Best regards,

    Silviu.


    http://www.rosoftlab.net/



    • Edited by Lupu Silviu Tuesday, January 3, 2012 7:43 AM
    Tuesday, January 3, 2012 7:41 AM
  • Hi Leon

    Can you explain why/how a 2007/2010 document would get a docx extension?

    Why would you not save the files in the default docx format and install the Compatibility Pack on the XP/2003 machines so that they can open, edit and (if the user wishes) save in that file format?

    For security reasons, the newer versions of Word (2007, 2010) aren't very forgiving when it comes to the file extension not matching the content type.

    One possibility would be to check the document content before the document is opened, but this isn't going to be something easily done with VBA as it doesn't have the necessary tools to "crack open" an OpenXML Package to check the content. But for this purpose, the approach described here:
    http://www.jkp-ads.com/articles/Excel2007FileFormat02.asp
    http://msdn.microsoft.com/en-us/library/dd819387(office.12).aspx
    http://www.java2s.com/Code/VBA-Excel-Access-Word/Windows-API/UsingVBAtoProgramOpenXMLFiles.htm

    Basically, if it's a *.doc file you won't be able to "open" it using the methods described because that's not a "zip" package.


    Cindy Meister, VSTO/Word MVP
    Tuesday, January 3, 2012 8:11 AM
    Moderator
  • Somebody is doing something wrong if you have docx format documents with doc extensions - Word does not do this itself - but both Word 2007 and Word 2010 will open them, so something else is causing your crash.
     
    However, in addition to what Cindy has said, if all you want to do is check if a file is old or new format, you don't need to go to the lengths described in the linked articles; you can just look at the file signature.
     
        Dim FileName    As String
        Dim FileNum     As Long
       
        Dim Signature   As Long
        
        FileName = "C:\Path\To\Document.doc"
        FileNum = FreeFile
        Open FileName For Binary Access Read As FileNum
        Get FileNum, , Signature
        Close FileNum
       
        Select Case Signature
            Case &H4034B50
                ' File is a Zip Archive - assume docx/docm file
            Case &HE011CFD0
                ' File is a Compound Binary File - assume doc file
            Case Else
                ' File is not a Document
        End Select

       

    Enjoy,
    Tony
    www.WordArticles.com
    • Marked as answer by Masig Wednesday, January 4, 2012 2:38 PM
    Tuesday, January 3, 2012 5:36 PM