+ Reply to Thread
Results 1 to 6 of 6

Renaming text file to docx after free file

  1. #1
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    Renaming text file to docx after free file

    Hello I have code that creates a text file from free file object. Is possible to rename text file after it get created to a word file extension? I tried to use function called "name" from Microsoft knowledge base but word file got corrupted and I couldn't read it when opening it. Is there any other way?

  2. #2
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    Re: Renaming text file to docx after free file

    I forgot to give my code sample. Here it is that causes the problem.

    Please Login or Register  to view this content.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    38,021

    Re: Renaming text file to docx after free file

    You can't just change the file extension of a .txt file to .docx to make it into a Word file. A .docx has a much more complex file structure, hence the reason that Word thinks the file is corrupt.

    You'd need to open the .txt file in MS Word and save it as a .docx file.
    Trevor Shuttleworth - Excel Aid

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    Re: Renaming text file to docx after free file

    So does that mean that I create the text file first the way I'm doing it and then run the shell to open it in word and save as using the word method?

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    38,021

    Re: Renaming text file to docx after free file

    You're running VBA code in Excel ... I don't know why you're doing that.

    By put anyway, you could use the VBA code to open Word, open the .txt file in Word and then save the file as .docx.

    Not really my area of expertise ... but that's the theory.

  6. #6
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    Re: Renaming text file to docx after free file

    I know that is theory but I was searching for a way without using word object and instance because that's too much code and too much hassle for me. But if that only way then okay

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] File format converted from .txt to . docx
    By nur2544 in forum Word Formatting & General
    Replies: 3
    Last Post: 05-30-2019, 12:03 PM
  2. [SOLVED] How to create docx file
    By RAFA_NADAL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-21-2018, 06:13 AM
  3. Export a cell containing text into a .docx file - keep formatting
    By ocor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2014, 05:28 PM
  4. [SOLVED] .DOCX File - Unable to add text to fields
    By DavoP in forum Word Formatting & General
    Replies: 4
    Last Post: 05-08-2014, 03:38 AM
  5. Replies: 0
    Last Post: 08-23-2013, 07:57 AM
  6. Replies: 15
    Last Post: 08-27-2012, 10:13 AM
  7. Compiling .docx files into a single .xls file
    By Cheshire in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-11-2010, 03:46 PM

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.6.0 RC 1