Results 1 to 14 of 14
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What's the File format?

    I want my open dialog code to know the file format of the document being opened. Is there an property or something to test for or do I just examine the file extension and trust that as accurate?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: What's the File format?

    Hi Kevin,

    I think the extension is the best way to go for files in general, but there is a Document Property Reader utility available from Microsoft that will give detailed information on most Office formats, especially Word and Excel. It can return the application that created the file. You can download This Thread if you don't mind visiting the XL forum.

    Andrew

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What's the File format?

    Thanks Andrew. I have tried DSOFile but found it wanting. If the document (file) being examined is protected with either a write or open password, DOSFile croaks.

    Also, there is a custom document property for Word generated html files (at least based on the Word template html.dot) called (appropriately enough) 'HTML' which takes either a boolean yes or no.

    This would work just fine except for the fact that not all html docs are created by MS products. Isn't that unbelievable?

    I guess the extension is reliable enough.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  4. #4
    JustCallMeAl
    Guest

    Re: What's the File format?

    Under Tools, Options, General (Word 97), there is the option to Confirm conversion at Open. Could tapping into that be of some help?

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What's the File format?

    That only freaks the user. I get the call "what do I do now". What I need is a way to test and take the necessary action in code -- out of the users hands and mind.

    Here's what I've settled with for now:

    if activedocument.savedformat <> 10 then
    'Do the non-html stuff here.
    endif

    I have no idea what savedformat 10 is. I just know that's what Word returns for an HTML document. Word 97 help only lists 8 formats and Word 2002 lists 10. I'm still developing in 97. Go figure. I wish the help would indicate which long value is represented by each constant. Drives me nuts having to write Select Case statements just to find out which one is which.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  6. #6
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Oregon, USA
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What's the File format?

    Hi Kevin,

    I seem to recall chrisgreaves attempting this from a hex perspective a while ago. Does this <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=vb&Number=26502&page=&v iew=&sb=&vc=1#Post26502>post</A> help as a starter?

    Chris

  7. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What's the File format?

    Hey, that just might do it. Thanks. I never would have remembered that...

    Thanks, Chris
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  8. #8
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: What's the File format?

    Hi Kevin,

    You can usually pretty reliably get the values for each constant by looking them up in the Object Browser - if you get "WdSaveClasses" into the "Classes" frame, you'll see "Members of WdSaveClass" enumerated in the frame to the right. Click on each one and you'll see its name and the long equivalent listed at the bottom.

    But here's the freaky part: I'm in Word 2000, there are 10 constants listed, but none of them have a number "10" - only have from 0 to 9! So "10" is a mystery member.

    Oh well, at least this method is usually helpful.

    Gary

  9. #9
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What's the File format?

    At least until Word97 the Extent-to-type mapping seems clumsy to me. I have found that when I want Word97/VBA to do the equivalent of "File, saveas HTML" that I have to physically locate the file converter on the machine; it varies from machine to machine, depending on how many File Converters have been installed, i.e. whether you have the Lotus Wordpro suite, Corel WordPerfect etc.

    Maybe this snippet helps.


    Bottom line for me is
    (1) extents aren't anywhere near foolproof enough (ask any virus writer)
    (2) filetypes/converters aren't standard at all
    (3) examining the hex type works
    ... and if you really want to be sure, you can't be sure, but a combination of all three ought to be better than any one of them.

    <pre> Dim fc As FileConverter
    Dim intTypeSave As Integer
    ' Determine Saveformat of HTML converter
    For Each fc In Application.FileConverters
    If UCase(fc.ClassName) = UCase(strType) Then
    intTypeSave = fc.SaveFormat
    strType = Left(strType, 3)
    Dim strFile As String
    strFile = strFileName & strcExtentSeparator & strType
    strFile = strReplaceAll(strFile, " ", "")
    If boolFileExists(strTargetPath & strFile) Then
    If blnOverwrite Then
    (snip!)
    </pre>


  10. #10
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What's the File format?

    Gary,

    Well, what do you know? I never noticed any relevancy to that info at the bottom!

    That is very useful. And wouldn't you know, none of the Word 97 constants for saveformat is 10 either. But it's definitely a valid (albeit undocumented) format.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  11. #11
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What's the File format?

    Chris,

    I think you're on to it here. I've got your code from previous posts so I hope I can put together a decent filetype checker for future use.

    As for now, I'm going to stick with that undocumented saveformat 10 (heck, it works and it's one line of code!)
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  12. #12
    JustCallMeAl
    Guest

    Re: What's the File format?

    Didn't mean to turn it on, but you should be able to access its decision as to what a file format is.

    However, I have looked more at file converts, and I have no other point to suggest.

  13. #13
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What's the File format?

    Right. It just may not work on the next computer you use, like the one at home, or in the cubicle next to yours.

    Or after you re-install your own system.

  14. #14
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What's the File format?

    I'll just turn a deaf ear to that advice, so there! (Knowing full well I'll get bit in the butt <img src=/S/moon.gif border=0 alt=moon width=15 height=15> one day soon.)

    Nevertheless, I'll let that one come back as a program enhancement or bug fix as soon as a user reports it. <img src=/S/innocent.gif border=0 alt=innocent width=20 height=20>
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •