I have the following macro code in a file, which was working perfectly till now from many days.
however, now suddenly I am experimenting this error on multiple systems. I haven't changed anything in the code.
Please help.
Error :
Basic Runtime Error
Device I/O Error
Code :
Code: Select all
Sub Main
Dim FileNo As Integer
Dim Filename As String
dim Currentline as string
Doc = ThisComponent
Sheet = Doc.Sheets(0)
Cell = Sheet.getCellRangeByName("C12")
caseid = Cell.String
'Cell2 = Sheet.getCellRangeByName("D12")
'EmpCode = Cell2.String
Cell3 = Sheet.getCellRangeByName("C14")
Rmks = Cell3.String
Cell4 = Sheet.getCellRangeByName("C15")
AMName = Cell4.String
Cell5 = Sheet.getCellRangeByName("C16")
CMs = Cell5.String
if len(cell5.string) >= 30 then
msgbox "Your comments have exceeded the limit, Enter only required information in comments." & vbcrlf & "Case NOT Submitted."
exit sub
end if
if cell5.string = "" or cell4.string = "" or cell3.string = "" or cell.string = "" then
msgbox "Please fill all the fields. You cannot leave any field blank."
exit sub
end if
Filename = "\\172.19.32.61\xxx\yyy\xxxx.txt" ' Define file name
FileNo = FreeFile ' Establish free file handle
Open Filename For Append As #FileNo
Print #FileNo, caseid & "^" & right(Environ( "USERNAME" ) ,6) & "^" & Rmks & "^" & AMName & "^" & date & "^" & CMs
Close #FileNo
Msgbox "Case Submitted Successfully."
End Sub