Create txt file with Excel VBA macro

Solved
Hello,
I would like to create an Excel macro that creates a txt file containing the content of a cell from the Excel project.
And that it is opened at the same time.
Thank you in advance.

Configuration: Windows 7 / Firefox 15.0.1

3 answers

  1. Hello,

    Sub create_TXT() Close path = "C:\directory" Open path & "File.txt" For Output As #1 Print #1, Worksheets("Sheet1").Range("A1") Close End Sub 


    And that it be opened at the same time.
    12
    1. Thank you for your response, but I’m just starting with VBA, and it’s not working :(
      And for "And that it should be opened at the same time. ????????" I mean that just after it is created, it should be opened, but that’s not a big deal.
      0
    2. There is an error
      "runtime error '75': path/file access error"
      0
    3. Re,

      the code should be placed in VBA in a module or in ThisWorkbook
      Did you set your directory to create your file??
      What do you want to open this .TXT file with: Excel, Notepad, or .......?
      0
    4. I placed it in a module yes I have my directory and the txt I want to open it with Notepad.
      (you can use "tu" with me)
      0
    5. Hi,
      Show your code.
      0