View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Nikos Yannacopoulos[_5_] Nikos Yannacopoulos[_5_] is offline
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/