Excel VBA中毫秒计时器分辨率的交叉兼容性 [英] Cross Compatibility of Millisecond Timer Resolution in Excel VBA

查看:105
本文介绍了Excel VBA中毫秒计时器分辨率的交叉兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在必须与Windows Excel 2007和Mac OS Excel 2011兼容的Excel VBA项目中获得小数计时器分辨率.Ive在Windows中找到了一种使用 .

I would like to get fractional timer resolution in an Excel VBA project that has to be compatible with Windows Excel 2007 and Mac OS Excel 2011. Ive found a method in windows utilizing sleep from kernel32.dll and a method on Mac OS using MacScript("GetMilliSec").

我目前对Mac的访问权限有限,因此我现在无法直接对其进行测试.如果我这样声明Sleep:

I currently have limited access to a Mac, so I am not able to test this out directly right now. If I declare Sleep like this:

Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

在Mac中打开文件会引发错误吗?还是仅当/如果在Mac中调用Sleep时才标记错误?

Will an error be raised when the file is opened in a Mac? Or will the error be flagged only when/if Sleep is called in a Mac?

推荐答案

我相信您需要使用条件编译来避免API声明在Mac上引起错误.

I believe you'll need to use conditional compilation to avoid your API declaration causing an error on a Mac.

   #If Mac Then
      MsgBox "I'm a Mac"
   #Else
      MsgBox "I'm a PC"
   #End If

这篇关于Excel VBA中毫秒计时器分辨率的交叉兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆