天道酬勤,学无止境

Date for VBA not working in Excel 2011?

Here is my code, I am attempting, which works BTW on a PC, but not on a Mac, to run this code and have an excel sheet created, named, add a tab, change the color of said tabs, change the name of said tabs, and then transpose the data while maintaining the format of the cells and width and height of the cells to the new worksheet.

This works, on a PC.... but when I get onto a Mac, it doesn't.

I go into References, and this is what I see.

enter image description here

I see Ref Edit Control, and Microsoft Scripting Runtime are missing. I disabled both, and the script gives me an error here still:

wbBK2.SaveAs Dir & Application.PathSeparator & "Open Order Report -" & Format(Date, "mm-dd-yyyy") & ".xlsx"

The error happens at the (Date, "mm-dd-yyyy") Specifically the Date section. I can't figure out why this is happening honestly. If someone can peruse this and give me an answer and a solution it be greatly appreciated.

The error I get is an Error '9 Subscript Out Of Range I can't see a reason why this error only shows up on a Mac, and not a PC.

Option Explicit

Sub OpenOrderReportExport()

    Dim wsJL As Worksheet   'Jobs List
    Dim wsPOT As Worksheet  'PO Tracking
    Dim wsTNO As Worksheet  'Tel-Nexx OOR
    Dim wsDOO As Worksheet  'Dakota OOR
    Dim wbBK1 As Workbook   'Open Order Report
    Dim wbBK2 As Workbook   'New Workbook
    Dim wsWS1 As Worksheet  'Sheet1
    Dim wsWS2 As Worksheet  'Sheet2
    Dim wsWS3 As Worksheet  'Sheet3
    Dim wsWS4 As Worksheet  'Sheet4
    Dim CurrentFile As String, NewFileType As String, NewFile As String, Dir As String, lastrow As Long

    Set wsJL = Sheets("Jobs List")      'Jobs List
    Set wsPOT = Sheets("PO Tracking")   'PO Tracking
    Set wsTNO = Sheets("Tel-Nexx OOR")  'Tel-Nexx OOR
    Set wsDOO = Sheets("Dakota OOR")    'Dakota OOR
    Set wbBK1 = ThisWorkbook
    Set wbBK2 = Workbooks.Add           'New Workbook
    Set wsWS1 = wbBK2.Sheets("Sheet1")  'Sheet1
    Set wsWS2 = wbBK2.Sheets("Sheet2")  'Sheet2
    Set wsWS3 = wbBK2.Sheets("Sheet3")  'Sheet3


        Application.ScreenUpdating = False    ' Prevents screen refreshing.
        CurrentFile = ThisWorkbook.FullName
        NewFileType = "Excel Files 2007 (*.xlsx)"
        Dir = ThisWorkbook.path & Application.PathSeparator & "Reports"
        wbBK2.SaveAs Dir & Application.PathSeparator & "Open Order Report -" & Format(Date, "mm-dd-yyyy") & ".xlsx"
        Sheets.Add After:=Sheets(Sheets.Count)

    Set wsWS4 = wbBK2.Sheets("Sheet4")  'Sheet4

        With wbBK2
            Dim Sht As Worksheet
                For Each Sht In Worksheets
                    Sht.Tab.Color = 255
                Next
        End With

        Sheets("Sheet1").Name = "Jobs List"
        Sheets("Sheet2").Name = "PO Tracking"
        Sheets("Sheet3").Name = "Dakota OOR"
        Sheets("Sheet4").Name = "Tel-Nexx OOR"

        With wbBK1
            'Jobs List Export
            lastrow = wsJL.Range("B" & Rows.Count).End(xlUp).Row
            wsJL.Range("A2:N2").Copy
            wsWS1.Range("A1").PasteSpecial xlPasteAll
            wsJL.Range("A3:N" & lastrow).Copy
            wsWS1.Range("A2").PasteSpecial xlPasteValuesAndNumberFormats
            wsWS1.Range("A2").PasteSpecial xlPasteColumnWidths
            wsJL.Range("B3:N" & lastrow).Copy
            wsWS1.Range("B2").PasteSpecial xlPasteFormats
            wsWS1.Columns("A").Delete

            'Tel-Nexx Export
            lastrow = wsTNO.Range("B" & Rows.Count).End(xlUp).Row
            wsTNO.Range("A2:Q2").Copy
            wsWS2.Range("A1").PasteSpecial xlPasteAll
            wsTNO.Range("A3:Q" & lastrow).Copy
            wsWS2.Range("A2").PasteSpecial xlPasteValuesAndNumberFormats
            wsWS2.Range("A2").PasteSpecial xlPasteColumnWidths
            wsTNO.Range("B3:Q" & lastrow).Copy
            wsWS2.Range("B2").PasteSpecial xlPasteFormats
            wsWS2.Columns("A").Delete

            'Dakota Export
            lastrow = wsDOO.Range("B" & Rows.Count).End(xlUp).Row
            wsDOO.Range("A2:O2").Copy
            wsWS3.Range("A1").PasteSpecial xlPasteAll
            wsDOO.Range("A3:O" & lastrow).Copy
            wsWS3.Range("A2").PasteSpecial xlPasteValuesAndNumberFormats
            wsWS3.Range("A2").PasteSpecial xlPasteColumnWidths
            wsDOO.Range("B3:O" & lastrow).Copy
            wsWS3.Range("B2").PasteSpecial xlPasteFormats
            wsWS3.Columns("A").Delete

            'PO Tracking Export
            lastrow = wsPOT.Range("B" & Rows.Count).End(xlUp).Row
            wsPOT.Range("A2:K2").Copy
            wsWS4.Range("A1").PasteSpecial xlPasteAll
            wsPOT.Range("A3:K" & lastrow).Copy
            wsWS4.Range("A2").PasteSpecial xlPasteValuesAndNumberFormats
            wsWS4.Range("A2").PasteSpecial xlPasteColumnWidths
            wsPOT.Range("B3:K" & lastrow).Copy
            wsWS4.Range("B2").PasteSpecial xlPasteFormats
            wsWS4.Columns("A").Delete
        End With

        With wsWS1
            .Activate
            .Range("A1").Select
        End With
End Sub

评论

the MISSING references are what are causing the problems. Remove the checkmarks there, and the basic stuff like date will start working again. If those references are critical to the code you are running, you will have to search out the Mac equivalents

More about references - normally resolving "Missing" fixes it, but, from here

What you're describing is typical of corrupted references. This can be caused by a referenced file being a different version or in a different location between the machine on which the code was developed, and the client machines. Our company also tries to keep all the machines configured the same way, but I've found it's essentially impossible to manage.

Open any code module (or open the Debug Window, using Ctrl-G, provided you haven't selected the "keep debug window on top" option). Select Tools | References from the menu bar. Examine all of the selected references.

If any of the selected references have "MISSING:" in front of them, unselect them, and back out of the dialog. If you really need the reference(s) you just unselected (you can tell by doing a Compile All Modules), go back in and reselect them.

If none have "MISSING:", select an additional reference at random, back out of the dialog, then go back in and unselect the reference you just added. If that doesn't solve the problem, try to unselect as many of the selected references as you can (Office may not let you unselect them all), back out of the dialog, then go back in and reselect the references you just unselected. (NOTE: write down what the references are before you delete them, because they'll be in a different order when you go back in)

Yes, disambigulating as VBA.xxxx will work, since Excel no longer has to look through all of the references.

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

相关推荐
  • Dir()函数在Mac Excel 2011 VBA中不起作用(Dir() function not working in Mac Excel 2011 VBA)
    问题 嗨,我正在尝试列出Excel工作簿所在子目录中的所有文件。由于某些原因,代码无法执行Dir功能。 任何人都可以请教吗? 谢谢! Sub ListFiles() ActiveSheet.Name = "temp" Dim MyDir As String 'Declare the variables Dim strPath As String Dim strFile As String Dim r As Long MyDir = ActiveWorkbook.Path 'current path where workbook is strPath = MyDir & ":Current:" 'files within "Current" folder subdir, I am using Mac Excel 2011 'Insert the headers in Columns A, B, and C Cells(1, "A").Value = "FileName" Cells(1, "B").Value = "Size" Cells(1, "C").Value = "Date/Time" 'Find the next available row r = Cells(Rows.Count, "A").End(xlUp).Row + 1 'Get the first file
  • VBA cDate 不适用于 Mac excel 2011(14.7.1)(VBA cDate not working on Mac excel 2011(14.7.1))
    问题 我正在尝试使用 VBA 脚本将日期转换为 long。 下面是代码片段 Sub test() Dim str as string Dim d as variant str="1/1/2016" d=cdate(str) end sub 上面的代码段在 Windows 上运行良好,但在 MAC 上给了我类型不匹配错误。 在日期中转换有效字符串是否有任何周转。 回答1 您的区域设置是根本原因。 你可以尝试修改它们吗? defaults write NSGlobalDomain AppleICUDateFormatStrings -dict 1 dd/MM/yyyy 回答2 您的代码确实在我的本地 OS X 机器上使用 Excel 运行。 不过,我有不同的区域设置。 我建议尝试使用国际日期格式(“YYYY-mm-dd”)。 Sub Main Dim str as String Dim d as Variant str = "2016-01-01" d = CDate(str) End Sub 或者,您可以尝试“2016 年 1 月 1 日”。 PS:您可以在 OS X 中的系统偏好设置 -> 语言和地区 -> 高级 -> 日期下查看您的日期和时间设置: 回答3 许多不同的答案,所以我不妨把这种做法扔进戒指, Sub test() Dim str As String Dim d As
  • vba,excel:返回此字符串数组中最早的日期值(vba, excel : returning the earliest date value in this array of string)
    问题 我在编码方面遇到了一些问题,不知道在哪里解决这个问题: 我希望 BronzeDate 返回在我的数组中找到的最早日期。 这是打印输出的示例: Possible Bronze Date : 6/6/2011 Possible Bronze Date : 10/5/2011 Possible Bronze Date : 10/5/2011 Possible Bronze Date : 12/5/2011 Possible Bronze Date : 10/5/2011 Possible Bronze Date : 6/6/2011 Possible Bronze Date : 11/5/2011 Possible Bronze Date : 1/16/2012 Possible Bronze Date : 6/6/2011 Possible Bronze Date : Possible Bronze Date : Possible Bronze Date : Possible Bronze Date : Possible Bronze Date : Possible Bronze Date : Possible Bronze Date : Possible Bronze Date : Possible Bronze Date : Possible Bronze Date :
  • Dir() function not working in Mac Excel 2011 VBA
    Hi I am trying to list all the files in a subdirectory of where the Excel workbook is residing in. For some reason, the code cannot execute beyond the Dir function. Can anyone please advise? Thank you! Sub ListFiles() ActiveSheet.Name = "temp" Dim MyDir As String 'Declare the variables Dim strPath As String Dim strFile As String Dim r As Long MyDir = ActiveWorkbook.Path 'current path where workbook is strPath = MyDir & ":Current:" 'files within "Current" folder subdir, I am using Mac Excel 2011 'Insert the headers in Columns A, B, and C Cells(1, "A").Value = "FileName" Cells(1, "B").Value =
  • 任何有关 EXCEL 中 SQL 和 Microsoft OLE DB Provider for Jet 4.0 的参考/手册?(Any references/manuals on SQL in EXCEL with Microsoft OLE DB Provider for Jet 4.0?)
    问题 是否有任何有关EXCEL 中SQL 语法的参考/手册与 Microsoft OLE DB Provider for Jet 4.0 相关联? 例如,如何编写日期类型的常量? 有哪些关键字/功能/子句可用? 回答1 当使用 Excel 作为 Jet 4.0 数据源时,我所知道的最佳参考是: 如何将 ADO 与来自 Visual Basic 或 VBA 的 Excel 数据一起使用。 特别重要的是,当现有列包含混合数据类型时,如何确定现有列的整体数据类型。 关于 Microsoft OLE DB Provider for Jet 4.0,最相关的文章是这样的: ADO 提供程序属性和设置:Microsoft Jet 4.0 提供程序属性 也就是说,在较早的文章中更好地介绍了 Excel 特定的详细信息。 使用 Excel 和 SQL 时应注意的一个重要问题: BUG:使用 ActiveX 数据对象 (ADO) 查询打开的 Excel 工作表时发生内存泄漏 有哪些关键字/功能/子句可用? 关于使用 Jet 4.0 SQL,这篇文章是我见过的最好的: 中级 Microsoft Jet 4.0 SQL 从理论上讲,Access Help 的 SQL 部分应该是相关的,但它的质量特别低,而且 Jet 4.0 的覆盖率特别低。 同样,并非所有内容都可以直接在 Excel 中运行。 例如
  • vba, excel : returning the earliest date value in this array of string
    i'm having some issues with the coding and not sure where to fix this: I would like the BronzeDate to return the earliest date found in my array. This is examples of the print out: Possible Bronze Date : 6/6/2011 Possible Bronze Date : 10/5/2011 Possible Bronze Date : 10/5/2011 Possible Bronze Date : 12/5/2011 Possible Bronze Date : 10/5/2011 Possible Bronze Date : 6/6/2011 Possible Bronze Date : 11/5/2011 Possible Bronze Date : 1/16/2012 Possible Bronze Date : 6/6/2011 Possible Bronze Date : Possible Bronze Date : Possible Bronze Date : Possible Bronze Date : Possible Bronze Date : Possible
  • VBA cDate not working on Mac excel 2011(14.7.1)
    I am trying to convert a date into long using VBA script. Below is the code snippet Sub test() Dim str as string Dim d as variant str="1/1/2016" d=cdate(str) end sub The above snippet runs fine on windows but is giving me type mismatch error on MAC. Is there any turnaround to convert a valid string in a date.
  • 用于带日期循环的 Excel VBA 脚本(Excel VBA script for loop with dates)
    问题 我正在计算两个给定日期之间的工作小时数(上午 8 点到晚上 8 点),不包括周末和公共假期,但我的代码语法不正确。 样本数据: 开始日期:17/06/2011 08:00:00 AM 结束日:19/06/2011 08:00:00 PM Sub SLA_Days_Resolved_F() Dim x As Integer ' Set numrows = number of rows of data. NumRows = Range("F2", Range("F2").End(xlDown)).Rows.Count Dim total As Integer 'to count the total hours Dim st As String 'start date cell Dim en As String 'end date cell Dim destCell As String Dim d As Date ' for the loop total = 0 ' Establish "For" loop to loop "numrows" number of times. For x = 2 To NumRows + 1 st = "G" & CStr(x) 'reference to the cells en = "D" & CStr(x) 'loop from start
  • 为表达式设置两个变量的 VBA EXCEL 多个嵌套 FOR 循环(VBA EXCEL Multiple Nested FOR Loops that Set two variable for expression)
    问题 好吧,我已经做了大量的搜索,找到了一些,玩了一点。 我似乎无法让这些循环完全工作,我可以部分完成,但不能全部完成。 由于第一个循环工作正常,然后它变得不稳定。 T是表达式输出t.Value = time1 - time2 Y是设定不变的时间日期= time1 X是时间和日期,必须从与相应y相同的列中的范围中提取。 x= time 2 我已经上传了我的工作簿的相应部分 https://docs.google.com/open?id=0BzGnV1BGYQbvMERWU3VkdGFTQS1tYXpXcU1Mc3lmUQ 我玩过重新排列 for 循环的条件退出。 我什至考虑过尝试 goto,直到我注意到它的提及创建了一大堆尸体。 我对任何建议或方向持开放态度并感激不尽。 我注意到一些语言有退出和继续选项,但它没有出现 VB 吗? 这是我的循环,我已经去除了在尝试让它工作时造成的混乱。 Sub stituterangers() Dim dify As Boolean Dim difx As Boolean Dim time2 As Date Dim time1 As Date For Each t In range("d7:cv7") For Each x In range("d8:cv11") If x > 0 Then time2 = x For Each y In range(
  • Excel VBA script for loop with dates
    I am calculating the number of work hours (8am to 8pm) between the 2 given dates, excluding Weekends and Public holidays, but my code syntax is incorrect. Sample data: Start day: 17/06/2011 08:00:00 AM End day: 19/06/2011 08:00:00 PM Sub SLA_Days_Resolved_F() Dim x As Integer ' Set numrows = number of rows of data. NumRows = Range("F2", Range("F2").End(xlDown)).Rows.Count Dim total As Integer 'to count the total hours Dim st As String 'start date cell Dim en As String 'end date cell Dim destCell As String Dim d As Date ' for the loop total = 0 ' Establish "For" loop to loop "numrows" number of
  • 在Excel中解析ISO8601日期/时间(包括TimeZone)(Parsing an ISO8601 date/time (including TimeZone) in Excel)
    问题 我需要将Excel / VBA中包含时区(来自外部来源)的ISO8601日期/时间格式解析为正常的Excel日期。 据我所知,Excel XP(我们正在使用的)没有内置的例程,因此我想我正在考虑使用自定义VBA函数进行解析。 ISO8601日期时间看起来像其中之一: 2011-01-01 2011-01-01T12:00:00Z 2011-01-01T12:00:00+05:00 2011-01-01T12:00:00-05:00 2011-01-01T12:00:00.05381+05:00 回答1 有一种(合理的)简单方法可以使用公式而不是宏来解析没有时区的ISO时间戳。 这与原始发布者的要求不完全相同,但是当我尝试在Excel中解析ISO时间戳时发现了这个问题,并且发现此解决方案很有用,所以我想在这里分享一下。 下面的公式将再次解析ISO时间戳,而不带时区: =DATEVALUE(MID(A1,1,10))+TIMEVALUE(MID(A1,12,8)) 这将以浮点格式生成日期,然后您可以使用常规Excel格式将其格式化为日期。 回答2 很多Google搜寻没有任何结果,所以我编写了自己的例程。 将其发布在此处以供将来参考: Option Explicit '--------------------------------------------------------
  • BSTR's and VARIANT's under… mac os x
    Under mac os x I have office 2011 and its excel and VBA, and I have gcc-5.3.0's g++. I played a lot to passing arrays (of numerical built-in types) from VBA to the dylib (extension of dll's on mac os x) and updating them and sending them back to VBA, see for instance : passing c/c++ dylib function taking pointer to VBA on mac Now, I would like to do the same with strings, and first with just one string, not an array. I want to receive the string from VBA, modify it in C++, and send it back, updated, to VBA. The code on the C++ side is : #include <stdlib.h> #include <ctype.h> //for toupper
  • BSTR's 和 VARIANT's under... mac os x(BSTR's and VARIANT's under… mac os x)
    问题 在 mac os x 下,我有 office 2011 及其 excel 和 VBA,我有 gcc-5.3.0 的 g++。 我在将数组(数字内置类型)从 VBA 传递到 dylib(mac os x 上的 dll 扩展)并更新它们并将它们发送回 VBA 方面做了很多工作,例如参见: 传递 c/c++ dylib 函数,将指针指向 mac 上的 VBA 现在,我想对字符串做同样的事情,首先只使用一个字符串,而不是数组。 我想从 VBA 接收字符串,在 C++ 中修改它,然后将它发回,更新,到 VBA。 C++端的代码是: #include <stdlib.h> #include <ctype.h> //for toupper extern "C" { void toupperfunc(char *vbstr) { size_t i = 0U; char c; do { c = vbstr[i]; vbstr[i]=toupper(c); ++i; } while(vbstr[i]!=0); } } 在文件thedylib.dylib ,编译如下(office 2011 for mac os x 是 32 位): g++ -m32 -Wall -g -c ./thedylib.cpp g++ -m32 -dynamiclib ./thedylib.o -o ./thedylib
  • Parsing an ISO8601 date/time (including TimeZone) in Excel
    I need to parse an ISO8601 date/time format with an included timezone (from an external source) in Excel/VBA, to a normal Excel Date. As far as I can tell, Excel XP (which is what we're using) doesn't have a routine for that built-in, so I guess I'm looking at a custom VBA function for the parsing. ISO8601 datetimes look like one of these: 2011-01-01 2011-01-01T12:00:00Z 2011-01-01T12:00:00+05:00 2011-01-01T12:00:00-05:00 2011-01-01T12:00:00.05381+05:00
  • Mac Excel 2011 VBA UDF 不起作用 - SET 或 FIND 命令似乎是问题所在(Mac Excel 2011 VBA UDF not working - SET or FIND command seems to be the issue)
    问题 我正在将电子表格从 Excel 2007 转换为 Mac Excel 2011。我已经尝试了几个小时来解决我的问题,但没有成功,因此我们将不胜感激! 此 UDF 在范围内查找字符串,然后返回找到的单元格下方一个单元格的值。 SET 命令在 Mac 版本中不返回任何内容,但在 Excel 2007 中有效。 Function FindRng(Fnd As String) Application.Volatile Dim Rng As Range If Fnd = "" Then FindRng = 0 GoTo 109 End If With Sheets("Matrix").Range("G2:FZ13") Set Rng = .Find(What:=Fnd, _ After:=.Cells(2, 7), _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not Rng Is Nothing Then FindRng = Sheets("Matrix").Cells(Rng.Row + 1, Rng.Column).Value Else FindRng = 0 End If End With 109
  • Mac Excel 2011 VBA UDF not working - SET or FIND command seems to be the issue
    I am converting a spreadsheet from Excel 2007 to Mac Excel 2011. I have tried for hours to solve my problem, without success, so any help would be appreciated! This UDF finds a string in a range, then returns the value one cell below the found cell. The SET command returns nothing in the Mac version, but works in Excel 2007. Function FindRng(Fnd As String) Application.Volatile Dim Rng As Range If Fnd = "" Then FindRng = 0 GoTo 109 End If With Sheets("Matrix").Range("G2:FZ13") Set Rng = .Find(What:=Fnd, _ After:=.Cells(2, 7), _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _
  • Passing a VARIANT from mac OS X Excel 2011 VBA to c++
    I am under mac OS X, and using excel-2011 vba. I know how to pass various types from VBA to c++ and inversely, mainly thanks to this. Now, I would like to know if it is possible to somehow pass a VBA variant to c++ (I am using gcc 5.2). Of course, there's no VARIANT in gcc but, after all, VARIANT is "just" a union. (The optimistic guy.) Have you guys heared about classes mimicking microsoft's VARIANT and allowing to achieve this ? (In the first time, I could accept to forget about IUnknown and IDispatch !) I am aware of mono, and looked what I could get from it, as they also have a
  • VBA代码从Mac Excel 2011中的Mysql DB中获取数据(VBA code to fetch data from Mysql DB in Mac Excel 2011)
    问题 我在Windows中使用ADODB代码从Mysql Database中获取数据,并且工作正常。 但是,我似乎无法使我的Excel工作簿(使用ADODB)与Excel Mac 2011一起使用。经过大量的搜索之后,我发现了来自Actual tech的ODBC连接器,并且能够使用Microsoft Query来获取三行。 但是我希望使用VBA代码完成此操作,但一直无法做到。 有没有人得到这个工作? 如果是,请您提供示例代码。 提前致谢 !! PS:我知道有一个类似的现有问题,但是答案中提供的链接不再起作用。 因此,我问了一个新问题 此外,如果有人需要通过Microsoft Query进行链接,则这里是链接:http://www.agentjim.com/MVP/Excel/2011Relational7Queries.html 这是我在Windows中使用的代码: Sub getMysqlDBdata() Dim Cn As Object Dim sqlQa as string dim temparray1 as variant Source = "MySQL" mysql_driver = "MySQL ODBC 5.2 ANSI Driver" sqlQa = "select * from test.TestTable;" Set Cn = CreateObject(
  • 将 VARIANT 从 mac OS X Excel 2011 VBA 传递到 C++(Passing a VARIANT from mac OS X Excel 2011 VBA to c++)
    问题 我在 mac OS X 下,使用 excel-2011 vba。 我知道如何将各种类型从 VBA 传递到 C++,反之亦然,这主要归功于这一点。 现在,我想知道是否有可能以某种方式将 VBA 变体传递给 C++(我使用的是 gcc 5.2)。 当然,gcc 中没有VARIANT但毕竟VARIANT “只是”一个联合。 (乐观的家伙。)你们听说过模仿微软的VARIANT并允许实现这一目标的类吗? (第一次,我可以接受忘记IUnknown和IDispatch !) 我知道单声道,并查看我能从中得到什么,因为它们也有一个VARIANT类,但我不知道它是否明智。 我找了一个文档,详细解释了excel-2011 for mac的对象模型,没有成功。 精确。 我并不是说 microsoft 的VARIANT是在 Windows 下,在 c++ 和 excel 之间交换数据的最佳方式,但是,对于 COM 和 ATL 之类的东西,我已经很习惯了,它对我的​​工作很有效,所以我正在尝试在 mac OS X 下坚持“同类”的东西。我可能是错的,但在这种情况下,我真的很想知道我如何做我想做的事。 回答1 我最终选择将VARIANT移植到 mac os x,请参见此处: BSTR's 和 VARIANT's under... mac os x 我在那里描述了我现在如何尝试做到这一点。
  • VBA:在 Excel for Mac 2011 中通过 Outlook 发送邮件(VBA: Send mail via Outlook in Excel for Mac 2011)
    问题 在 Mac 上,Office 2011(最新补丁)我想通过 Outlook 发送邮件 Set mailer = CreateObject("Outlook.Application") 这给出了错误 ActiveX 组件无法创建对象 这似乎可信,因为 Mac 上没有 ActiveX。 我试图找到替代解决方案,但是 他们已经过时了 (2011) 宏必须同时在 Mac 和 Windows 上运行 目前在 Office Mac 2011 中通过 Outlook 发送邮件的最佳 VBA 方式是什么? 回答1 参见/http://msdn.microsoft.com/en-us/library/hh859489(v=office.14).aspx 正如您所注意到的,Mac 没有ActiveX组件。 对于你的 VBA,使用上面的链接来处理 Mac 的情况,并使用if语句(见下面的伪代码): If Application.OperatingSystem = "MAC" Or Application.OperatingSystem = "Macintosh" OR ... DoMacSendMail Else DoWindowsSendMail End If