excel-vba-mac

How to open a workbook from Excel 16 with VBA on MAC?

我的梦境 提交于 2019-12-11 03:35:01
问题 I want to open a simple workbook from a little macro with the VBA of Excel 16 on a MAC 10.10 but I can't. I have my macro: Sub Test() Call Workbooks.Open("Classeur1.xlsm") End Sub With Office 11, this function works fine but I have an error with Office 16: Run-time error '1004': Application-defined or object-defined error Do you have any idea to fix it please? 回答1: The problem is Excel 2016 for Mac has a strange "default" directory that it works in. Mine starts up in /Users/xxxxx/Library

What does “=R[-115]C” mean in VBA for Excel 2011 on Mac?

六月ゝ 毕业季﹏ 提交于 2019-12-10 22:19:03
问题 What does " =R[-115]C " mean in VBA for Excel 2011 on Mac in below code? Range("F171").Select 'to select a cell ActiveCell.FormulaR1C1 = "=R[-115]C" 回答1: It's the offset from the cell that the formula is in. The example you posted... "=R[-115]C " ...would be offset by -115 rows in the same column, so would be equivalent to =F56 . You can do the same thing with the columns. This... Range("A1").Select ActiveCell.FormulaR1C1 = "=RC[1]" ...would give you the formula =B1 . 来源: https:/

Query a closed workbook without opening it

拈花ヽ惹草 提交于 2019-12-10 18:56:55
问题 I'm searching for a string within a column of a closed Excel workbook. The following code gives a type mismatch error on MsgBox. If I replace that line with ret = "'" & wbPath & "[" & wbName & "]" & wsName & "'!" & Range("C3015").Address(True, True, -4150) then the macro gives me a hard-coded value (in this case, the value at cell C3015). How can I search for other values within columns of closed workbooks, without opening them? Dim wbName As String, wbPath As String, wsName As String wbPath

How to check which line of VBA code is causing errors

╄→гoц情女王★ 提交于 2019-12-10 01:39:45
问题 I am trying to debug a long code I wrote and I need to step line by line. The thing is I am on a mac and don't know how to use an F8 in that case. Could anyone tell me how can I do that otherwise and how do I know which line is causing problems with execution? 回答1: To check which line is giving you the error, you can use the ERL property. See this sample code below. Sub sample() Dim i As Long On Error GoTo Whoa 10 Debug.Print "A" 20 Debug.Print "B" 30 i = "Sid" 40 Debug.Print "A" 50 Exit Sub

VBA: save cell contents to text file in a specific location on Mac

吃可爱长大的小学妹 提交于 2019-12-08 08:34:59
问题 I'm really new to VBA, and I'm trying write a macro that will save the contents of some specifc cells to a specific location on my Mac. The whole code works fine, EXCEPT that it won't save to the right location; all files save to the desktop. Basically, A1 starts out containing something like this "260 - CategoryA - 555.555.555.555 - 2012-11-06 17:43:49," and I want the macro to save the contents of column A, rows 2-61 to a text file named after the first 3 numbers in cell A1. The location I

ActiveX component can’t create object — Excel for Mac

坚强是说给别人听的谎言 提交于 2019-12-07 18:32:45
问题 I’m trying to get an Excel 2011 32-bit (for Mac) spreadsheet working that contains a macro. The problem is that this macro works fine on a PC, but not on the Mac. I tried to import Tim Hall’s Dictionary.cls, but it still doesn’t work. Same thing for KeyValuePair.cls. Error: Run-time error ’429’ ActiveX component can’t create object I’m not a programmer, so the problem is probably me, not knowing what to change to get things working. It’s probably super easy for those who know what they are

How can I determine if my VB code is running on Office 2016 for Mac?

二次信任 提交于 2019-12-07 12:30:52
问题 Is there a conditional that I can use to differentiate if my Macro is running on Office 2016 for Mac or Office for Mac 2011 回答1: In Office 2016 for Mac, there is a new conditional called MAC_OFFICE_VERSION to test which VB version the user is running. The following example shows how it to use it in your code: Sub VersionConditionals() #If MAC_OFFICE_VERSION >= 15 Then Debug.Print "We are running on Mac 15+" #Else Debug.Print "We are not running on Mac 15+" #End If #If Mac Then Debug.Print "We

Create Word file from Excel 2011

会有一股神秘感。 提交于 2019-12-06 08:10:39
The usual approach to create a Word document from Excel VBA: Set WD = CreateObject("Word.Document") results in an error when run with Excel 2011. Any idea how a Word document can be created in Excel 2011 with VBA? (I do not want to use AppleScript as I want the program to be able to run on PCs also.) The following code, based on the suggestion by bretville, seems to work both on mac (tested on Excel2011) and on pc (tested on Excel2007) and can be run repetedly, thus allowing creation of multiple Word files. What is required for the code to work under Excel2011 (mac) vba is a means to test if

ActiveSheet vs. WorkSheet

情到浓时终转凉″ 提交于 2019-12-06 05:57:15
I'm using Excel for Mac 2011, and I have a couple Check Boxes in one sheet. I'm trying to automate them with the following code: Private Sub CheckBox12_Click() Dim ws As Worksheet Set ws = ActiveSheet With ws If .Shapes("CheckBox12").OLEFormat.Object.Value = xlOn Then .Range("CK1").EntireColumn.Hidden = False Else .Range("CK1").EntireColumn.Hidden = True End If End With End Sub This code gives me the error: Run-time error 445 Object does not support this action. However if remove ws and just do Private Sub CheckBox12_Click() With ActiveSheet If .Shapes("CheckBox12").OLEFormat.Object.Value =

How can I determine if my VB code is running on Office 2016 for Mac?

て烟熏妆下的殇ゞ 提交于 2019-12-05 20:02:53
Is there a conditional that I can use to differentiate if my Macro is running on Office 2016 for Mac or Office for Mac 2011 In Office 2016 for Mac, there is a new conditional called MAC_OFFICE_VERSION to test which VB version the user is running. The following example shows how it to use it in your code: Sub VersionConditionals() #If MAC_OFFICE_VERSION >= 15 Then Debug.Print "We are running on Mac 15+" #Else Debug.Print "We are not running on Mac 15+" #End If #If Mac Then Debug.Print "We are running on a Mac" #Else Debug.Print "We are not running on a Mac" #End If End Sub Note: The "#If Mac"