Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Automatic File Naming in Visual Basic?
Imagine the data is in 5 columns of a specific worksheet. The first 4 columns are used to be printed in a specific text file.
What is the code to make the text file named after the data in the last column i.e. <name>.txt and stored in a specific directory?
Thanks!
2 Answers
- 1 decade agoFavorite Answer
Dim file As System.IO.FileStream
Dim S1 As String
Dim theFileName As String
Dim S2 As String
Dim S3 As String
//Chr(34) is the ascii code for "
S1="Chr(34)c:\"
S2=".txtChr(34)"
S3=S1 & theFileName & S2
file = System.IO.File.Create(S3)
Dim retval As String
retval = Dir$("c:\vbfiles\b.txt")
If retval = "b.txt" Then
MsgBox "b.txt exists--no need to copy it..."
Else
FileCopy "c:\vbfiles\a.txt", "c:\vbfiles\b.txt"
End If
End Sub
For the directory thing see this:
- 5 years ago
has there been a modern-day installation or reinstallation of excel ninety seven? oftentimes while VB can not be stumbled on it is because of the fact it hasn't been put in. that's an determination while setting up office97 (and different variations) to characteristic VB besides. it is not computerized; a custom set up should be achieved for it to be extra.