Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 09-10-2009
Member
 
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.
Reply With Quote
  #2  
Old 09-10-2009
Member
 
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.
Quote:
Shell "notepad.exe C:\somefolder\myfile.dat"
Reply With Quote
  #3  
Old 09-10-2009
Member
 
Join Date: May 2008
Posts: 2,008
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.

Quote:
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
Reply With Quote
  #4  
Old 09-10-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
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:
Quote:
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to use VBA to Open an excel file in notepad"
Thread Thread Starter Forum Replies Last Post
How To Open .ods File in MS Excel? Aagman Windows Software 7 10-02-2012 09:06 AM
Excel 2007 file fails to get permission to open in Excel 2011 Raju Chacha Windows Software 6 13-01-2012 09:17 PM
Configuring Internet Explorer 8 to open Excel file in to Microsoft Excel Aaghaz Technology & Internet 4 13-02-2011 10:37 AM
Open an Excel file from VB6 hatred Windows Software 2 26-03-2009 01:30 PM
Pdf file open in Excel Clemens Windows Software 3 06-02-2009 07:40 AM


All times are GMT +5.5. The time now is 08:23 PM.