open a text file with Word

Discussion in 'Questions (Windows Mobile)' started by mwaite, Jun 14, 2007.

  1. mwaite

    mwaite Member Licensed User

    I'd like to open a text file for viewing by launching it's associated filetype application. Windows registry default for txt files is Pocket Word, however I can't figure out how to open a txt file to pword.exe via B4P.

    These two commands will open a pwd file:
    Shell(pword.exe, "-opendoc \temp\readme.pwd")
    Shell(pword.exe, "\temp\readme.pwd")

    However using a txt extension instead fails. Word opens, but errors with "A problem with the document was encountered and it cannot be opened". I can double-click the same txt file in Explorer and it opens properly in Word.

    I suspect there's another attribute for opening non-native formats?

    Searching the Web has failed me.
     
  2. specci48

    specci48 Well-Known Member Licensed User

    Hmm... on my WM5 device there is no problem opening .txt files with PocketWord through the shell command.
    I testet small and big, ascii and unicode files but everything worked fine.

    specci48
     
  3. Cableguy

    Cableguy Expert Licensed User

    I believe You should only shell the file(.txt,.doc, etc) itself as the known associated app will automatically be started...
     
  4. mwaite

    mwaite Member Licensed User

    still treading water, and sinking fast

    Cableguy - I seem to be able to shell the file itself only on the PC. On the PDA it does nothing, no error, no anything. I even confirmed that shell command is being exectued shell("myfile.txt","") and shell("myfile.txt") does nothing.

    specci48 - can you please confirm or provide the shell command you used? I don't understand what could be different if you can open these file types and I cannot. Looks like I have the standard txt file extension type leading to pword.exe in the registry, but I can't open it.

    Thanks guys!
     
  5. Cableguy

    Cableguy Expert Licensed User

    If you can open a .doc file by tapping it, ten shelling should work, I would suggest you to use a regestry editor and browse the extension association keys to see if they are correct...
     
  6. mwaite

    mwaite Member Licensed User

    Cableguy,

    I have done that from the beginning. I suspect if there was a problem with registry association then perhaps I should be able to shell to some other file type, but so far trying to open files like pdf, ppt, doc, txt, htm, jpg, mp3 directly via Shell all fail, yet I can click on them in Explorer and their respective application launches and opens the file.

    Using the .txt file type as an example, I have the following in the registry:

    HKEY_CLASSES_ROOT\.txt >> default = txtfile
    so then if I go to txtfile:
    HKEY_CLASSES_ROOT\txtfile\Shell\Open\Command >> default = pword.exe %1
    and also
    HHKEY_CLASSES_ROOT\txtfile\Shell\OpenDoc\Command >> default = pword.exe -opendoc %1

    Could you please verify you have these values?

    And you are able to launch, say a text file call test.txt in \temp folder:
    Shell("\temp\test.txt") or Shell("\temp\test".txt,"") (figure one of these would work)
    and this will open pword with the contents of test.txt?

    If so man I'm stumped. Wonder if Resco Explorer could have anything to do with it? It's a pretty powerful Explorer replacement and, lack of any other suspect, wonder if it could be doing some reassigning?

    Appreciate the continued assistance!!
     
  7. specci48

    specci48 Well-Known Member Licensed User

    Hi mwaite,

    the code I used is
    Code:
    Shell("pword.exe","\temp\test.txt\")
    which is not diffeent from yours.

    I checked my registry and found additional entries like

    HKEY_CLASSES_ROOT\.txt >> Content Type = text/plain
    HKEY_CLASSES_ROOT\txtfile\ >> Default = txt
    HKEY_CLASSES_ROOT\txtfile\ >> EditFlags = 65535


    specci48
     
Loading...