Results 1 to 11 of 11
  1. #1
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts

    Default Plain text for certain Word filetype?

    I have a file type this is set up and associated to MS Word 2010. What I would *like* to do is have files with that extension saved as plain text.

    I know, I could use a plain text editor, but I need the citation functions and bibliography functions of Word as well -- AND, it has a specific extension. I can select just plain text when I save it, and fiddle with the extension, but that is more steps.

    Is there a way to just tell Word "Any time it has this extension save it as plain text"?

    Regards,
    Chuck Billow
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by CWBillow View Post
    I know, I could use a plain text editor, but I need the citation functions and bibliography functions of Word as well
    The use of citation & bibliography functions seems at odds with your 'plain text' file definition. Any citation & bibliography fields would be lost in a plain text file.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts
    Paul, it's not really, due to the circumstance. I want to be able to produce text, cited, and then the resulting biography (placed in the document) that is then, ideally, posted to a given DB. That not being possible I suppose I could copy and paste, but then I would undoubtedly have formatting issues if it didn't originate as plain text.

    I get that I can do what I need with a series of steps. It would just be nice to be able to write and cite the text, run the bibliography at the document bottom, and then post the entire thing straight away. DB's tend to have issues with Word's formatting codes at times.

    Besides / on top of that

    I set up a new document type with a unique extension, and associated it with Word, thinking that at least that would be a start in the process, but n-o-o-o-o-o-o... Word wants to save it as Word 6 format.

    So this is not turning into a slam dunk.

    Chuck
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    If all you want as the end result is a text file, you could just assign a 'SaveAs' macro to a keyboard combination and use that.

    If all you want from the document is the text, to paste into Access, you don't even need to save the document (or you could leave it in Word format) - there are other VBA methods to do that.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Chuck

    The basic process is to write macros that hijack the built-in Save commands of FileSave and FileSaveAs. This is done by creating macros with those names. There would be a need to add error catching to handle various complications but the starting macro might be something along the lines of the following.
    Code:
    Sub FileSave()
      Dim sName As String, sParts As Variable, sExt As String
      sName = ActiveDocument.FullName
      sExt = Split(sName, ".")(UBound(Split(sName, ".")))
      Select Case sExt
        Case "myext"
          ActiveDocument.SaveAs FileName:=sName, FileFormat:=wdFormatText
        Case Else
          ActiveDocument.Save
      End Select
    End Sub
    Next, you need to work out where these macros get stored. They will probably need to be in the Normal template since the text files can't have an attached template. This will mean the macros will be active on every file you open with Word and so if you get something wrong, it will break a lot of files before you work out there is a problem.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Rather than hijacking the FileSaveAs command, I'd be inclined to run a separate macro that activates the SaveAs dialogue.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. #7
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts
    That sorta works Paul (although I did it manually, no Talent Yet). When I "Save As" it, somehow the indenting on the bibliography gets lost, but it's fixable.

    Thanks,
    Chuck Billow
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  8. #8
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts
    Thanks Andrew! I'll give that a fling.

    Thanks,
    Chuck
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  9. #9
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts
    Wouldn't the "hijacking" only occur while the macro is run / running? Would just being available in Word need to cause a problem?

    Regards,
    Chuck
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  10. #10
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by CWBillow View Post
    When I "Save As" it, somehow the indenting on the bibliography gets lost, but it's fixable.
    Text files don't have any formatting, including indenting. All they have is plain characters. You can use tabs or spaces to simulate indents, but that's fairly crude and is really only viable if the content still fits on one line.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  11. #11
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Hijacking the save functionality is bad because if you get it wrong, you won't be able to save ANY files in Word regardless what file extension they have. Yes it won't be a problem until someone tries to save but the software is pretty useless if you can't save your work

    You would need to test your macro extensively because of odd edge cases such as:
    1. Can you actually 'save' a text file opened with Word or is this really a 'Save As' function since the document isn't doc/docx/docm
    2. What happens if someone cancels the Save As dialog
    3. What happens if someone has a doc file and wants to save to plain text
    4. What happens if someone has a text file and wants to save to doc
    5. What happens if someone tries to save with an invalid filename
    etc

    Paul's suggestion of using a macro that doesn't hijack the built-in functionality is much safer since you elect when you want to run it.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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