Detecting file type in vba for word

I have directories full of files on a Mac.  Most of these files are Doc files, some Txt files and some other types. Unfortunately the files don't have file extensions (not hidden but actually no file extensions).  On a PC in a macro I need to open
these  doc files (from the Mac) and do some manipulations on the files and then save them.  I have a macro which works as long as all the files are Doc files so if I can detect the file type in my macro I can skip the non-Doc files and process only
the Doc files.
Is there a way in a vba for word macro to detect a file type other than by the file extension?  Or if that can't be done can I put error trapping on my Open statement that will catch an attempt to Open a non-Doc type file?
Thanks
Harry Spier

If your code is running on Windows and you are in a position to install software on it, you
may be able to get reasonably reliable detection using dsofile.dll, which you can get here:
I really do not know whether it will work with files stored or create on Mac (and in any case, if these are old Mac .doc files, you may find that Windows Word cannot open them anyway.
You need to
 - register the dll via regsvr32
 - in VBE, use Tools->References... to make a reference to"DSO OLE Document Properties Reader 2.1"
 - use code such as the sample below. 
Option Explicit
Function IsWordDoc(FullName As String) As Boolean
' FullName is the full path name of the file you want to check
Dim objDocumentProperties As DSOFile.OleDocumentProperties
IsWordDoc = False
Set objDocumentProperties = New DSOFile.OleDocumentProperties
' or you can add dsoOptionOnlyOpenOLEFiles to the options and
' use error trapping to detect -2147217148
objDocumentProperties.Open sFileName:=FullName, ReadOnly:=True, Options:=dsoOptionDontAutoCreate
If objDocumentProperties.IsOleFile Then
If objDocumentProperties.OleDocumentFormat = "MSWordDoc" Then
IsWordDoc = True
End If
End If
objDocumentProperties.Close savebeforeclose:=False
Set objDocumentProperties = Nothing
End Function
Sub testIsWordDoc()
Debug.Print IsWordDoc("c:\a\test.doc")
Debug.Print IsWordDoc("c:\a\test.xls")
End Sub
You may also find that the value of the property I am checking varies and that you need to look at other things, such as 
objDocumentProperties.SummaryProperties.ApplicationName
but that value definitely varies according to the version of Word used to create the .doc, so you would need to discover what values it can have in a valid .doc.
Peter Jamieson

Similar Messages

  • File Type and Size for Video iPod

    I have the latest ipod that does it all, but I am a little concerned about the lack of control on the file type size. I can export a mp4 file with my own settings so it isn't such a large file but it won't load or play. I can convert the file but it makes it the standard file size which is larger than I want it to be. Isn't there a way to save my own settings and still have it play video?
    Thanks for any info from anyone.

    I want to save a higher and better compression and not such high quality settings as the ipod standards settings are.
    You can't.
    http://www.apple.com/quicktime/tutorials/creatingvideo.html
    Video formats supported:
    H.264 video up to 768 Kbps, 320 x 240, 30 frames per sec., Baseline Profile up to Level 1.3 with AAC-LC up to 160 Kbps, 48 KHz, stereo audio in .m4v, .mp4 and .mov file formats;
    MPEG-4 video up to 2.5 Mbps, 480 x 480, 30 frames per sec., Simple Profile with AAC-LC up to 160 Kbps, 48 KHz, stereo audio in .m4v, .mp4 and .mov file formats

  • What video file type is best for quicktime?

    I have a Macbook Pro and use Quicktime to play videos I download from p2p programs. I often find that many of the videos do not work. Messages such as "this is not a video file." and "additional software is needed to play this video" often pop up.
    Is there a certian file type (mp4, mov, etc.) that works best that I should look for? If not, what can I do to prevent this?
    Thanks for any help.

    The formats that QuickTime 7.x can natively handle can be found here:
    http://www.apple.com/quicktime/player/specs.html
    In addition to those, a number of additional formats can be played with the addition of third-party codecs such as Perian and the Flip4Mac codecs. Some other codecs also exists, for very specific systems such as Avid.

  • What Video file type is required for upload to Captivate 8?  I have uploaded an .mp4 video to my slide and the HTML5 tracker indicates that the slide/object is unsupported

    Need help asap on this question - does this need to be an .FLV file?  There seems to be a lot of conflicting information on this.

    Hi
    I am using a MAC
    Captivate 8.0.1.242
    Multi-slide synchronized so I can set the slide timing to accommodate length of video
    The problem is specifically with .flv video files when publishing a responsive project or even trying to play the slide.  The video encoder pops up trying to convert the file to .mp4 for output but does not work.  My understanding is that the ONLY video file type I can use for responsive projects is .flv
    Is this correct?
    Caitlin Tomelden
    Cloud Services University Program Manager
    Intelisys
    Supporting the Industry's Top Producers
    707.238.8133 Direct
    [email protected]<mailto:[email protected]>
    www.intelisys.com<http://www.intelisys.com/>
    Connect with us:   <http://www.facebook.com/Intelisys>     <http://twitter.com/#!/intelisyscorp>     <http://www.linkedin.com/company/intelisys>

  • Not sure about derviatives, file types, and export for lightroom

    hello:
    I am a new LR user and new to the DAM process. I am confused about something that is probably basic and fundamental to this process. My computer setup is two internal drives (working drive and a photo archive), as well as external backup and burning to dvd. Using LR for both image adjustment and catalog management (not using Photoshop).  For raw I will be converting to dng on ingestion. I will add bulk metadata on ingestion and then bring images into LR to rate images and make basic image adjustments. These images will then be archived as originals.
    Now, if I perform additional work on any of these archived images (addl. image adjustment or metadata) would these images be considered derviatives?  If so, would I then go to export in LR to add to file name (e.g., masterfile, master.dng or .tif) before sending to, for instance, a working derviative folder before sending off to the archive?
    Also, if I am sending these images to archive, but not sending out for email or web, do I need to change the dng to another file type (e.g., tif)?
    Lastly, I have some old jpegs on media cards that I want to put through this process. Is there anything special that I need to do in handling these images versus dealing with raw?
    I have read the DAM book as well as reading through various online resources, but this whole process is quite confusing for a beginner.
    Please respond anytime.
    Thanks
    joe.

    Lightroom is a non-destructive editor. This may be different than anything you have used in the past.
    With non-destructive editors, there is no concept of original and derivative (unless you choose to use a 2nd program like Photoshop, sounds like you're not planning to do that). With a non-destructive editor, you make your changes in the editor (Develop Module), and these instructions are stored by Lightroom as a "recipe" and not as a distinct file on your hard disk. These instructions about your edits are applied whenever you use Lightroom to view your image (or whenever you choose to print from Lightroom or make a slidesehow from LR or make a web page from LR). The original is completely unchanged, and there is no edited derivative photo exported or saved. Thus, there is no need to segregate original and edited photo, because there is no saved edited photo. Additional edits in Lightroom are handled the same, original is unchanged, your edits are stored, and there is no derivative or saved photo.
    The only time you would save a copy of the photo is if you wanted a copy for some non-Lightroom purpose, in which case you use File->Export... to make a file on disk in a "temporary" folder, then you use the file created in whatever non-Lightroom purpose you have, and when completed, you can delete the file in the temporary folder, knowing that LR can re-create it exactly if you ever need it again. If you are going to print from LR, or e-mail from LR, or create a web page from LR, or create a slideshow from LR, you do not need to create an exported photo.
    JPGs and RAWs and DNGs are all handled the same by you, the user. Yes, there is internal differences that aren't important to your workflow.

  • Best video file type to convert for Apple TV???

    I just got the Apple TV and love it, but I have a ton of AVI's and whatnot that obviously won't play.  What would you all recommend is the best thing to do with them?  I have converting software, but want to choose the right file type that will not make it 2-3X the size.  Appreciate tips!!!!

    Old thread for others, but,,... It isnt necessary to convert a bunch of files, if you have Plex on your pc, and on your iphone/ipad.
    I would have spent a month converting the terra bytes of all the video files that I had but i just airplay and my Plex app to send nearly any type of file on my Imac directly to my Apple tv.
    It converts on the fly any file that isnt supported.

  • Best video file type to export for iPod?

    Am using Premiere to edit movies, and was wondering what is best file format to export for eventual iPod conversion to get the best quality?

    I am not familiar with Premiere, but below are the limits which are supported:
    H.264 video up to 768 Kbps, 320 x 240, 30 frames per sec., Baseline Profile up to Level 1.3 with AAC-LC up to 160 Kbps, 48 KHz, stereo audio in .m4v, .mp4 and .mov file formats;
    MPEG-4 video up to 2.5 Mbps, 480 x 480, 30 frames per sec., Simple Profile with AAC-LC up to 160 Kbps, 48 KHz, stereo audio in .m4v, .mp4 and .mov file formats
    H.264 will give the best quality and smallest file sizes, but the price of this is time, H.264 conversion is time consuming as it is very processor intense.

  • Inserting a page break below an image using VBA for Word

    Hi all,
    I am trying to have about 50 screen shots in one file, automatically crop and resize each image, then add a page break at the end of each image, but then move down to the next screen shot and repeat this process to the end of the file.
    So far, I have figured out the code to select the image, crop it down to a specific size, then blow the image up to the right size.  When I try to add a page break at the end of those first few commands, it keeps putting the page break above the image. 
    Does anyone have any suggestions?
    Here is the current code I am using to accomplish the above;
    Sub ResizeImage()
        If Word.Selection.Type = wdSelectionInlineShape Then
            Set ishp = Word.Selection.Range.InlineShapes(1)
            ishp.LockAspectRatio = False
            ishp.PictureFormat.CropBottom = 130
            ishp.PictureFormat.CropTop = 220
            ishp.PictureFormat.CropLeft = 340
            ishp.PictureFormat.CropRight = 340
            ishp.Height = InchesToPoints(3.5)
            ishp.Width = InchesToPoints(6.5)
        End If
    ' insertpagebreak Macro
        Selection.TypeParagraph1
        Selection.InsertBreak Type:=wdPageBreak
    End Sub
    Any help would be so appreciated, and also any guideance as to how to get this code to repeat itself until the end of the page (have not even come close to figuring that out yet).  Big picture is to get all screen shots down to the pertinent information
    and then have each image on it's own piece of paper so we can print them out for account reconciliation backup.
    Thank you in advance,
    Larissa Boydston

    Hi Larissa,
    >> When I try to add a page break at the end of those first few commands, it keeps putting the page break above the image.
    The reason of this is that it adds the page break at the start of range. We could adjust the range to deal with it.
    >> also any guideance as to how to get this code to repeat itself until the end of the page
    You could iterate all InlineShape objects of current document or current section range.
    There is the simple code that you could refer to:
    Dim s As Word.InlineShape'For each s In InlineShapes
    For Each s In Word.Selection.Range.InlineShapes
    Range(s.Range.End, s.Range.End).InsertBreak Type:=wdPageBreak
    Next s
    Regards
    Starain
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Detect file type of binary or ascii

    Is there a clean way to detect for a file its type, either binary or ascii. More specifically, given an arbitrary file, I want to check it to see if it is an ascii file or a binary file. If the file is binary, I want to check it again to see what possible binary type it is: gzip, excel doc, pdf doc, etc.
    What tips can you provide.
    Thanks.

    You could perhaps use a similar convention to perl:
    http://www.perldoc.com/perl5.6/pod/func/X.html
    The -T and -B switches work as follows. The first block or so of the file is examined for odd characters such as strange control codes or characters with the high bit set. If too many strange characters (>30%) are found, it's a -B file, otherwise it's a -T file. Also, any file containing null in the first block is considered a binary file. If -T or -B is used on a filehandle, the current stdio buffer is examined rather than the first block. Both -T and -B return true on a null file, or a file at EOF when testing a filehandle. Because you have to read a file to do the -T test, on most occasions you want to use a -f against the file first, as in next unless -f $file && -T $file.

  • Which file type to use for editing

    I recently filmed a school talent show to create DVDs for the parents. I'll be using PrE 9 to edit. I understand the output for the movie will need to be MPEG2 for the DVD. We used three different cameras (I know this is a bad thing to do with PrE), but we used what we have available. Though, we did use a GoPro Hero2 mounted on the piano to give a unique perspective. Consequently I need to convert the video files into a common format for editing. Is there a "best" file format to edit in or is there a file format that is easiest to work with in Premiere Elements while maintaining the best quality for the DVD output?
    Here is what we used:
    Camera 1 (with the audio track from the sound board) was a Canon Vixia HF300. It exported in the dreaded .mts format (half the show at 24mbps and half at 17mbps)
    Camera 2 was a Nikon 5100 as .mov files, 1920x1080, H.264, Linear PCM, Total bit rate 19k
    Camera 3 was a GoPro Hero 2 recorded .mp4 1280x780 H.264 Total bit Rate 15k
    Since the aspect ratios are not equivalent, I plan on using black bars as opposed to cropping.
    I'm editting on an Apple MacBookPro 2.66GHz Intel Core 2 Duo with 8gb RAM running OSX 10.7
    Also, should I use Quicktime to convert these files into the common format I choose? Ironically, all this footage is editable in iMovie, but iMovie is horrible for multi-camera.
    Thanks,
    Ed

    Over on the Windows side of the aisle where I am, I would say convert all to DV AVI since the end will be a DVD, not a BluRay
    For Mac, I guess the SD version of DV AVI in the MOV wrapper
    I have some saved discussions & links, but have NO idea if any of these places have Mac versions
    Tools to Convert to DV-AVI http://forums.adobe.com/thread/415317
    Convert http://premierepro.wikia.com/wiki/FAQ:How_do_I_convert_my_files%3F
    Convert your HD files to DV-AVI Type II with 48KHz 16-bit Audio
    As well as the links just above, use Google to find conversion software
    I have NOT used the products below, I only forward due to other mentions... so YMMV and all the usual disclaimers... check the links and read to find out if one of the products listed below will rip or convert the files you have to something you need for editing
    http://www.corel.com/servlet/Satellite/us/en/Product/1175714228541#tabview=tab0
    http://www.womble.com/products/mvw.html
    http://www.magix.com/us/movie-edit-pro/ plus $5 Ship
    http://www.nchsoftware.com/prism/index.html
    http://www.videoredo.com/en/index.htm
    http://www.nchsoftware.com/prism/index.html Converter
    http://www.daniusoft.com/media-converter-ultimate.html
    http://www.deskshare.com/dmc.aspx Digital Media Converter
    http://www.any-dvd-ripper.com/any-dvd-ripper-windows.html
    http://www.deskshare.com/dvd-ripping-software.aspx
    http://www.dvdcopysoftware-reviews.com/dvd-cloner/
    http://www.topsoftwareol.com/product/Video/Video_Converter_Standard.html
    http://www.erightsoft.com/SUPER.html Multi-Converter <-- supposed to be very good
    http://download.cnet.com/FreeStar-Free-Video-Converter/3000-2194_4-10854990.html
    http://www.dvddecrypter.org.uk/ or http://www.mrbass.org/dvdrip/
    http://www.flaskmpeg.net/download.php Mpeg to AVI Converter
    http://www.squared5.com/ MPEG Streamclip Converter
    http://www.virtualdub.org/ Mpeg to AVI Converter
    http://www.sothinkmedia.com/video-converter/
    http://www.videohelp.com/tools/XviD4PSP

  • Best file type and size for logo?

    I should know this but I am going to ask anyway. I am have a local graphic artist create a new logo for me. It needs to be keyed in my show opening, segues, and close. The program is shot and edited in 720p but sometimes 1080p. The larger the better for scaling down? I am always lost when it come to this topic.
    Thanks in advance.
    Cheers.
    Tom

    As Russ said, it is better to scale down than up.
    Let me add this: if possible, the original file for the logo should use vectorial graphics. This way it won't have a fixed size, and can resized without any loss of quality. This should not be a problem if, for example, the logo is created in Illustrator (formats like eps, pdf, svg can contain vector data). Vector files are also usually smaller in size, although that is probably not a bi consideration here.
    Then you can make rasterized versions at different sizes, as needed. You'll probably use a png file in the video, as png supports alpha channel (transparency).

  • Default file type has changed for Illustrator CS5.1 - Please help!

    I am using Illustrator CS5.1 and have just noticed that whenever I try to open a new document (file/New...) the document is a PDF instead of an AI file. How do I change it back to AI? - Not sure how it changed to PDF in the first place.

    How exactly  are you determining the file is a .pdf? What platform/OS version are you on? What file extension (letters after period) is on your files, what format does your save as show?
    If your icon is a .pdf icon and clicking on the file later opens in Acrobat, then your file association is not assigned properly.  On a Mac Command I on a selected file saved by illustrator, and change open with from acrobat to Illustrator, then click CHANGE ALL.
    There are more possibilities to why this can happen, please answer the questions at the beggining of this post should you need more help.

  • Testing for applications associated with a file type

    Dear contributors,
    while trying to open a simple *.txt file via java.awt.Desktop.open(File)
    the IOException is thrown. According to Javadoc there is "no associated
    application or the associated application fails to be launched" in this
    case. Interestingly the Desktop class does not provide methods to test
    for particular file type registration, just for the "support" of a generic
    Desctop.Action. Colud you please illuminate how to check, whether a file
    extension / file type / mime type has an associated application in a platform
    (in)dependent way at least for "opening" ?
    OS: Linux, 2.6.24-22-generic, x86_64
    JDK: 1.6.0_07, 64 bit
    Many thanks
    Jaro Pullmann

    If you make the call and an exception is thrown, then there is not application associated with the file type--otherwise I believe you need to do some registry work if you do not want a pretest.

  • LR 3.3 Import Dialog - Can imports be filtered by file type?

    I sometimes use a Canon S95 point and shoot and a workaround to have RAW images AND a certain aspect ratio (such as square) is to shoot with the RAW + JPEG setting. This allows me to shoot in any aspect ratio with out cropping in post. For this reason, my import dialog in LR shows both the RAW images and the corresponding JPEG images. Often I wish to simply dump the JPEGs and keep the RAWs.
    Is there any way to selectively check or select just the RAWs other than having to hand check each and every RAW while avoiding the JPEGs. In other words, is there a way to filter or segregate just what you want to import by file type.
    Thanks for your help!

    Ian, thanks so much for your reply. However that material in the link was WAY over my head. Now that I know that indeed I cannot filter by file type in the import dialog, I will simply import all and delete the JPEGs once in the library module where I can quickly filter by file type and delete the unwanted files there. Thanks for helping me out.

  • How to recognize file type (bytearray type)

    Hi,
    what ist the simplest way to detect file type or the type of byte[ ]? I mean, for example, how to detect if a "xyz.pdf" is a "really" PDF-File and not some Jpg with ".pfd"-extension.
    Thanx in advance
    vedran

    but there must be a easy wayIn general there is no requirement that a bunch of bytes belong to
    some unique "type". So there is no way to retrieve that type and, in
    particular, no easy way.
    If you want some pragmatic test (and I'm assuming that pdf was
    just an example - you want something general), you could have a
    look at the nix file command. It is open source and comes with
    a big set of useful files describing file headers. It is open source and
    can be seen, for example, here: ftp://ftp.gw.com/mirrors/pub/unix/file/

Maybe you are looking for

  • Cannot insert duplicate key row in object

    This is a JPA question. The tbHardware table has a PK identity column and a unique non-clustered index on CoxBarcode column. I have a SFSB in a Seam2.0.0.GA app running on JBoss 4.2.1.GA. I am using flushMode=FlushModeType.MANUAL (Seam specific when

  • UWL - Display SAP Inbox Documents in the Universal Worklist

    Hi, I'm working on the implementation of the UWL on EP 6.0. I do not succeed in getting the SAP Inbox documents in the UWL views. Does anybody know how to display these SAP Inbox documents in the UWL? Thanks a lot for your feedback. Gilles.

  • IMovie export error

    Running the latest version of Lion and Imovie 9.0.4 I keep getting the following error.  I don't know what file is causing the trouble. i have everything else closed while compiling the movie.  None of the files I am aware of are copyrighted.  I am u

  • What is causing random memory pressure surges?

    Running OS X Mavericks on a late 2012 iMac 27' 3.4GHz system with 32GB physical memory, with increasing frequency my system is slowed down to a crawl by random surges in memory useage-- can someone provide me some insight as to the cause?

  • New computer, exisiting iDisk data/files

    I just had to replace my hard drive in my Macbook. The Macbook has a fresh install of OS X (NOT a restore from backup). Most of my important files are on my .Mac (now MobileMe) iDisk. I would like to just mount my iDisk, and let all the files on the