2017-11-01 10 views
0

ここではすべてWindows上で正常に動作します  7.  の場合、window.MoveTo intLeft, intTopのタイプの不一致エラーが発生します。VBScriptでwindow.moveToで型の不一致エラーを修正するにはどうすればよいですか?

Sub Window_OnLoad 
    strComputer = "." 
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 
    Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor") 
    For Each objItem in colItems 
     intHorizontal = objItem.ScreenWidth 
     intVertical = objItem.ScreenHeight 
    Next 
    intLeft = (intHorizontal - 670)/2 
    intTop = (intVertical - 325)/2 
    window.ResizeTo 670,325 
    window.MoveTo intLeft, intTop 
End Sub 
+0

'intLeft'と' intTop'は整数であり、浮動小数点数ではありませんか? – Gurman

+0

どうやら彼らはどちらもNullです。 – xRuhRohx

答えて

0

したがって、問題はobjWMIServiceです。私はそれがWindowsで同じ動作しないと思います  10.

これは私がうまく動作するように見えた機能です。

array_ScreenRes = GetScreenResolution 
intHorizontal = array_ScreenRes(0) 
intVertical = array_ScreenRes(1) 

Function GetScreenResolution() 
    Set oIE = CreateObject("InternetExplorer.Application") 
    With oIE 
     .Navigate("about:blank") 
     Do Until .ReadyState = 4: WScript.Sleep 100: Loop 
     width = .Document.ParentWindow.Screen.Width 
     height = .document.ParentWindow.Screen.Height 
    End With 

    oIE.Quit 
    GetScreenResolution = Array(width, height) 
End Function 
関連する問題