Results 1 to 4 of 4

Thread: How to use VBA to Open an excel file in notepad

  1. #1
    Join Date
    Sep 2009
    Posts
    94

    How to use VBA to Open an excel file in notepad

    I would like to know that how can i use VBA code to open an excel file on a particular notepad. I had tried out my best in order to get proper solution for the above problem, but unfortunately didn't got any success in it. So, can any body tell me that how to open an excel file on a notepad by using VBA code? Does any body knows about it? Let me know the correct way for doing it.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to use VBA to Open an excel file in notepad

    According to me you should use the Shell command, in order to Open an excel file in notepad on your system.
    Shell "notepad.exe C:\somefolder\myfile.dat"

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: How to use VBA to Open an excel file in notepad

    If all you want to do is open the dat file in Notepad then with the help of shell method you would be able to do it. You can do something like this to make text files and write to them.

    Sub test()

    Open ThisWorkbook.Path & "\File1.txt" For Append As #1
    Print #1, Sheets(1).Range("A1").Value
    Close #1

    Open ThisWorkbook.Path & "\File2.txt" For Append As #1
    Print #1, Sheets(1).Range("A2").Value
    Close #1

    Open ThisWorkbook.Path & "\File3.txt" For Append As #1
    Print #1, Sheets(1).Range("A3").Value
    Close #1

    End Sub

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: How to use VBA to Open an excel file in notepad

    You originally said that you wanted to open the file in Notepad from within VBA code. Then you should try out the following code:
    RetVal = Shell("C:\WINDOWS\notepad.exe C:\myfile.txt", 1)
    Hope so it may help you to open an excel file in notepad using VBA.

Similar Threads

  1. How To Open .ods File in MS Excel?
    By Aagman in forum Windows Software
    Replies: 7
    Last Post: 10-02-2012, 09:06 AM
  2. Excel 2007 file fails to get permission to open in Excel 2011
    By Raju Chacha in forum Windows Software
    Replies: 6
    Last Post: 13-01-2012, 09:17 PM
  3. Replies: 4
    Last Post: 13-02-2011, 10:37 AM
  4. Open an Excel file from VB6
    By hatred in forum Windows Software
    Replies: 2
    Last Post: 26-03-2009, 01:30 PM
  5. Pdf file open in Excel
    By Clemens in forum Windows Software
    Replies: 3
    Last Post: 06-02-2009, 07:40 AM

Tags for this Thread

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
  •  
Page generated in 1,652,946,691.77456 seconds with 17 queries