简体   繁体   中英

Is there a way to create a date/time picker in a userform using VBA that will work on both windows and mac versions of excel?

我希望能够使用已经存在的日期选择器,但在Mac版本上不存在,因此Windows和Mac机器都可以访问此电子表格。

You can create a userform that acts as a DateTime Picker that will function on both Windows and Macintosh.

The most noticeable issue will be related to the difference in screen resolution between the two platforms. On the Mac, it's 96 dpi , where each dot represents a pixel . In Windows, screen resolution is 72 dpi (dots per inch) and each dot represents a point , while pixels are still 96 per inch .

Confusing the issue is that VBA in Windows uses points as the measurement unit for designing UserForms, while VBA on the Mac uses pixels . The result is that without applying any correction, UserForms that come out just right in Windows are only 75% as large on the Mac ...

A solution can be to add a procedure that re-sizes the userform accordingly, depending on which system is currently calling the procedure, something like:

Private Sub UserForm_Initialize()
  #If Mac Then
    ResizeUserForm Me
  #End If
End Sub

More info:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM