Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default send contents of cell b4 to a plain text file

Thank you Nikos


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default send contents of cell b4 to a plain text file

Got it. Thanks.


---
Message posted from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Link and plain text in the same cell Jim Excel Discussion (Misc queries) 4 January 28th 10 05:05 PM
changing cell value makes the formula plain text spandon Excel Worksheet Functions 1 December 22nd 09 04:59 PM
Import word file into excel as plain text Nick Excel Discussion (Misc queries) 1 June 23rd 08 04:22 PM
SAVE & SEND A FILE BASED ON TEXT IN A CELL VIA MACRO Pat Baratta New Users to Excel 1 February 26th 07 06:46 AM
hyperlinks and plain text in same cell? kec Excel Discussion (Misc queries) 4 June 7th 06 07:41 PM


All times are GMT +1. The time now is 05:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"