fry
Active Member
- Joined
- Apr 25, 2007
- Messages
- 411
Hi All
I've had the following code in a workbook for ages and all of a sudden it pops up with an error when I open it...
The error it pops up with is...
Run-time error '-2(fffffffe)':
Method 'Run' of object 'IWshShell3' failed
and upon clicking 'Debug', it highlights the following...
I'm stuck!!
Any help would be appreciated, thanks in advance
I've had the following code in a workbook for ages and all of a sudden it pops up with an error when I open it...
Code:
'Log time, user details & IP address
EndRow = Sheets("0 Log").Range("A4000").End(xlUp).Row + 1
Sheets("0 Log").Range("A" & EndRow).Value = Environ("USERNAME")
Sheets("0 Log").Range("B" & EndRow).Value = Application.UserName
Sheets("0 Log").Range("C" & EndRow).Value = Now()
Dim wsh As Object
Dim RegEx As Object, RegM As Object
Dim FSO As Object, fil As Object
Dim ts As Object, txtAll As String, TempFil As String
Set wsh = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set RegEx = CreateObject("vbscript.regexp")
TempFil = "C:\myip.txt"
' Save ipconfig info to temporary file
wsh.Run "%comspec% /c ipconfig > " & TempFil, 0, True
With RegEx
.Pattern = "(\d{1,3}\.){3}\d{1,3}"
.Global = False
End With
Set fil = FSO.GetFile(TempFil)
' Access temporary file
Set ts = fil.OpenAsTextStream(1)
txtAll = ts.ReadAll
Set RegM = RegEx.Execute(txtAll)
' Return IP address to Activesheet cell A1 by parsing text
'ActiveSheet.Range("A1").Value = RegM(0)
Sheets("0 Log").Range("D" & EndRow).Value = RegM(0)
'ActiveSheet.Range("A1").EntireColumn.AutoFit
ts.Close
' Remove temp file
Kill TempFil
Set ts = Nothing
Set wsh = Nothing
Set fil = Nothing
Set FSO = Nothing
Set RegM = Nothing
Set RegEx = Nothing
The error it pops up with is...
Run-time error '-2(fffffffe)':
Method 'Run' of object 'IWshShell3' failed
and upon clicking 'Debug', it highlights the following...
Code:
wsh.Run "%comspec% /c ipconfig > " & TempFil, 0, True
I'm stuck!!
Any help would be appreciated, thanks in advance