Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, I read file from EXCEL an 1

Status
Not open for further replies.

wuwang

Programmer
May 16, 2001
48
US
Hello,

I read file from EXCEL and write into a text file.
The output in the text file is SQL statments and the output
have double quote in tne beginning and in the end.

How to get rid of the double quotes in begin and in end????


For example, the output in text file is:
"Update table1 set dept = '01' Where id = 999"
"Update table1 set dept = '02' Where id = 9888"
"Delete table1 set Where id = 9999"

Here is my code:
Open ThisWorkbook.Path & "\testfile.txt" For Output As #1
For i = FirstRow + 1 To LastRow
vData0 = "Update eInventory_Inventory set "
For j = FirstCol + 1 To LastCol
....................





 
Hi,

There are several DIFFERENT methods to output to a sequential file. The way that you want, I believe, is the Print # methods...
Code:
    Print #1, "Update table1 set dept = '01' Where id = 999"

See if this helps :) Skip,
metzgsk@voughtaircraft.com
 
Hi,

There are several DIFFERENT methods to output to a sequential file with varying results.
The way that you want, I believe, is the Print # methods...
Code:
    Print #1, "Update table1 set dept = '01' Where id = 999"

See if this helps :) Skip,
metzgsk@voughtaircraft.com
 
Hi Skip,

It works. Thanks for much. YOU ARE GREAT.
 
Hello,

I have one more question need help.

Once my text file is created, how to have this file with read-only atrribute so the other people won't change anything in the text file. I need code example.

Your help will be very appreciate.




 
Code:
dim sFile as string
dim oFSO
dim oFile

sFile="c:\yourfile.txt"

set ofso=createobject("Scripting.FileSystemObject")
set ofile=ofso.getfile(sfile)

oFile.Attributes = 1' set readonly attribute

set ofile=nothing
set ofso=nothing


or you can use API

Private Declare Function SetFileAttributes Lib "kernel32" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long
 
Justin,

Good stuff -- worthy of a STAR :) Skip,
metzgsk@voughtaircraft.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top