Dim ws As Worksheet
Dim shp As Shape
Set ws = Thisworkbook.Worksheets("Sheet1")
Set shp = ws.Shapes("SHP1").Duplicate
With shp
.Top = ws.Range("B2").Top - .Height -5
.Left = ws.Range("B2").Left + (ws.Range("B2").Width - .Width) / 2
.Name = "SUB_SHP1"
.Visible = msoTrue
.OnAction = "RunXXX"
End With
Set shp = Nothing
Set ws = Nothing
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