Hi all.
Totally new to this forum, as I have a perplexing problem that Google just isn't solving for me.
At work, we have upgraded to some new version of MS Office, using VBA 7.1
I am trying to append text to a text file, qwhich woirks fine as long as I don't specify any file location.
As soon as I specify a file location such as "C:/", I get runtime errors.My current code works, and saves the file automatically in the "C:\Users\baror1\Documents" (where baror1 is my userID when I log into Windows):
Private Sub Command427_Click()
Open "7705-LOG.txt" For Append As #1
Print #1, Me.CircuitID
Print #1, Me.NE1String
Print #1, Me.NE2String
Close
End Sub
The code above works just fine, and appends the text in the specified fields, into a text file na,ed "7705-LOG.txt", and places it automatically in the folder I've listed above.
The problem is, other users need to use the log file too, so I don't want it saving to my personal folder, I'd rather just save it to a network drive, or just the C: drive.
I have tried the following, but I keep getting the error I mentioned above:
ATTEMPT 1:
Private Sub Command427_Click()
Dim File_Path As String
File_Path = " C:\7705-LOG.txt"
Open File_Path For Append As #1
Print #1, Me.CircuitID
Print #1,
Print #1, Me.NE1String
Print #1, Me.NE2String
End Sub
The code above produces the following error:
Run-time error '52':
Bad file name or number
My next attempt looks like this:
ATTEMPT 2:
Private Sub Command427_Click()
Open "C:/7705-LOG.txt" For Append As #1
Print #1, Me.CircuitID
Print #1, Me.NE1String
Print #1, Me.NE2String
Close
End Sub
The code above produces the following error:
Run-time error '75':
Path/file access error
I can guarantee there's no problems accessing the C drive, and there's nothing wrong with the file name, as it works just fine when I don't specify a path.
Can someone please help!!??
All the code I've looked up online says this should work... why doesn't it?
Totally new to this forum, as I have a perplexing problem that Google just isn't solving for me.
At work, we have upgraded to some new version of MS Office, using VBA 7.1
I am trying to append text to a text file, qwhich woirks fine as long as I don't specify any file location.
As soon as I specify a file location such as "C:/", I get runtime errors.My current code works, and saves the file automatically in the "C:\Users\baror1\Documents" (where baror1 is my userID when I log into Windows):
Private Sub Command427_Click()
Open "7705-LOG.txt" For Append As #1
Print #1, Me.CircuitID
Print #1, Me.NE1String
Print #1, Me.NE2String
Close
End Sub
The code above works just fine, and appends the text in the specified fields, into a text file na,ed "7705-LOG.txt", and places it automatically in the folder I've listed above.
The problem is, other users need to use the log file too, so I don't want it saving to my personal folder, I'd rather just save it to a network drive, or just the C: drive.
I have tried the following, but I keep getting the error I mentioned above:
ATTEMPT 1:
Private Sub Command427_Click()
Dim File_Path As String
File_Path = " C:\7705-LOG.txt"
Open File_Path For Append As #1
Print #1, Me.CircuitID
Print #1,
Print #1, Me.NE1String
Print #1, Me.NE2String
End Sub
The code above produces the following error:
Run-time error '52':
Bad file name or number
My next attempt looks like this:
ATTEMPT 2:
Private Sub Command427_Click()
Open "C:/7705-LOG.txt" For Append As #1
Print #1, Me.CircuitID
Print #1, Me.NE1String
Print #1, Me.NE2String
Close
End Sub
The code above produces the following error:
Run-time error '75':
Path/file access error
I can guarantee there's no problems accessing the C drive, and there's nothing wrong with the file name, as it works just fine when I don't specify a path.
Can someone please help!!??
All the code I've looked up online says this should work... why doesn't it?