Click here to Skip to main content
13,202,706 members (56,931 online)
Rate this:
Please Sign up or sign in to vote.
From VBS (VBScript), it is possible to call a Windows API indirectly via Excel app and one of its add-in function, CALL(), see for details the Office/Excel online help and the following MS webpage on CALL usage:

Following VBS code shows an example that obtains some information by making an indirect call to a Win API function, GetTickCount():
dim tmTicks
set xlApp = CreateObject("Excel.Application")
tmTicks = xlApp.ExecuteExcel4Macro("CALL(""Kernel32"",""GetTickCount"",""J"")")
Wscript.echo "Obtained tmTicks = " & tmTicks
set xlApp = nothing
This call is simple in that it passes in simple (-typed) args (/values) only, but I wonder how to call an API function that take more complicated arguments, e.g. structure-typed arguments - GetSystemTime() is an example which takes a structure containing 8 WORD-type elements for system time returned; in VBS, how to specify <type_text> argument as required by CALL() function? and how to specify a "structure" in VBS?

Thanks for explanation with concrete code example.
Posted 26-Feb-12 22:43pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171020.1 | Last Updated 27 Feb 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100