+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21

Thread: change .doc to .txt

  1. #16
    Registered User
    Join Date
    06-29-2011
    Location
    tennessee, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: change .doc to .txt

    Quote Originally Posted by snb View Post
    I think you must be able to adapt the code yourself, at least you are permitted to do so..
    I Dont know where to adapt it ive never made a macro in word and I dont know how to tell it to go there

  2. #17
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: change .doc to .txt

    Quote Originally Posted by snb View Post
    What value did you attribute to c00 ?
    Did you end it with a backslash ?
    c00 was:

    c00 = "C:\Test\"

    I was just testing it on a few 2003 doc files. Just tried again and same problem. It seems to create the files but instead of text like this:

    Test 1
    Test 1
    Test 1
    Test 1
    Test 1
    Test 1

    they end up looking like the attached.

    Dom
    Attached Files Attached Files
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #18
    Forum Guru Domski's Avatar
    Join Date
    12-14-2009
    MS-Off Ver
    What does it matter?
    Posts
    3,933

    Re: change .doc to .txt

    I assume this will work then:

    Sub LoopFiles()
    
    Dim strDir As String, strFileName As String
    
    strDir = "G:\Branham SW455S 3 Jun11\"
    strFileName = Dir(strDir & "*.doc")
    
    Do While strFileName <> ""
        Documents.Open strDir & strFileName
        strFileName = Left(strFileName, Len(strFileName) - 4) & ".txt"
        ActiveDocument.SaveAs FileName:=strDir & strFileName, fileformat:=wdFormatText
        ActiveDocument.Close
        strFileName = Dir
    Loop
    
    End Sub

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  4. #19
    Registered User
    Join Date
    06-29-2011
    Location
    tennessee, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: change .doc to .txt

    its still not working anything that you can think of that would make it not work right for me

  5. #20
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: change .doc to .txt

    @Domski

    Please post your code here (on my system: impeccable)
    I made a slight modification:

    sub snb()
      c00="E:\OF\"
      c01="doc"
      c02=dir(c00 & "*." & c01)
    
      do until c01=""
        with getobject(c00 & c02)
          c03=c03  & c02
          c04=c04 & "~|" & .content
          .activate
          .close 0
        end with
        c02=dir
      loop
    
      if c03<>"" then
        sn=split(replace(c03,".doc",".txt|"),"|")
        sp=split(mid(c04,3),"~|")
        for j=0 to ubound(sn)-1
          open c00 & sn(j) for output as #1
            print #1,sp(j)
          close
        next
      end if
    End Sub



  6. #21
    Registered User
    Join Date
    06-29-2011
    Location
    tennessee, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: change .doc to .txt

    i figured out the problem and fixed it thank you all for your help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0