Function CheckNumber(v as Varient) As Boolean
CheckNumber = True
If Len(v)=0 Then Exit Function
If IsNumeric(v) Then Exit Function
CheckNumber = False
End Function
とか記載したら、vに「a」とか入れてもTrueで返ってきてしまった。
Function CheckNumber(v as Varient) As Boolean
CheckNumber = True
If Len(Cstr(v))=0 Then Exit Function
If IsNumeric(Cstr(v)) Then
If InStr(Cstr(v),".")=0 Then Exit Function '小数じゃなかったら(簡易チェック)
End If
CheckNumber = False
End Function
Dim p As String
Dim res As Integer
On Error Resume Next
p = ThisWorkbook.Path
If Right(p, 1) <> "\" Then p = p & "\"
With CreateObject("WScript.Shell")
.CurrentDirectory = p // カレントディレクトリを変える
End With
res = Shell("test.exe", vbNormalFocus)
If res <> 0 Then Application.WindowState = xlMinimized
Dim xls As Object
Dim wb As Object
Set xls = CreateObject("Excel.Application")
xls.DisplayAlerts = False
Set wb = xls.Workbooks.Open(FileName:=[Excelパス], ReadOnly:=True)
・・・(読込処理)・・・
wb.Close SaveChanges:=False
Set wb = Nothing
xls.DisplayAlerts = True
xls.Quit
Set xls = Nothing