Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
send contents of cell b4 to a plain text file
How do I send the data in cell b4 to a plain text file
c:\data\description.txt Cell b4 contains a function and the result is some lengthy text data If the c:\data\description.txt file exists then it should be overwritten. --- Message posted from http://www.ExcelForum.com/ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
send contents of cell b4 to a plain text file
It just takes a few lines of VB code:
Sub export_text() textstring = Range("B4").Value Open "c:\data\description.txt" For Output As #1 Print #1, textstring Close #1 End Sub HTH, Nikos "lothario " wrote in message ... How do I send the data in cell b4 to a plain text file c:\data\description.txt Cell b4 contains a function and the result is some lengthy text data If the c:\data\description.txt file exists then it should be overwritten. --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
send contents of cell b4 to a plain text file
|
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
send contents of cell b4 to a plain text file
A follow up question - assume that the hostname on my PC is sdesk1 then
how can Open "c:\data\description.txt" For Output As #1 be changed so that the hostname is part of the filename so now it opens the file "c:\data\sdesk1_description.txt" insted of just "c:\data\description.txt" This description file is on network so I need to make sure that it is not overwritten by someone else on the network using the same script. --- Message posted from http://www.ExcelForum.com/ |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
send contents of cell b4 to a plain text file
Good point! You could easily use your computer name (is this what you are
referring to by host name?) or your Windows user name (or even both), assuming that no two PCs and no two users on the network will have the same name. It's good practice, as far as I am concerned. To get either through VB, you would use Environ("ComputerName") and Environ("UserName") respectively. So your code could be: unam = Environ("UserName") fnam = "C:\data\" & unam & "_description.txt" Open fnam for Output as #1 Or modify for computer name. HTH, Nikos "lothario " wrote in message ... A follow up question - assume that the hostname on my PC is sdesk1 then how can Open "c:\data\description.txt" For Output As #1 be changed so that the hostname is part of the filename so now it opens the file "c:\data\sdesk1_description.txt" insted of just "c:\data\description.txt" This description file is on network so I need to make sure that it is not overwritten by someone else on the network using the same script. --- Message posted from http://www.ExcelForum.com/ |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
send contents of cell b4 to a plain text file
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Link and plain text in the same cell | Excel Discussion (Misc queries) | |||
changing cell value makes the formula plain text | Excel Worksheet Functions | |||
Import word file into excel as plain text | Excel Discussion (Misc queries) | |||
SAVE & SEND A FILE BASED ON TEXT IN A CELL VIA MACRO | New Users to Excel | |||
hyperlinks and plain text in same cell? | Excel Discussion (Misc queries) |