1

I am absolutely new to VBA. I am trying to create a presentation such that content of each cell (in a row) creates a new slide in the presentation.

I searched for the code, but I could only find it for Windows. When I am trying to use the code on Mac - OS X 10.7.4 (Excel 2011), I am getting an error.

Need help :)!

Code and error are as follows:

Code:

code converted to text:

Sub OneSlideForEachRowCell()
'Open the Excel workbook. Change the filename here.
Dim OWB As New Excel.Workbook
Set OWB = Excel.Application.Workbooks.Open{":Users:vikshek:Desktop:list.xlsx")
'Grab the first Worksheet in the Workbook
Dim WS As Excel.Worksheet
Set WS = OWB.Worksheets(1)
'Loop through each used row in Column A
For i = 1 To WS.Range("A65536").End(xlUp).Row
  'Copy the first slide and paste at the end of the presentation
  ActivePresentation.Slides(1).Copy
  ActivePresentation.Slides.Paste(ActivePresentation.Slides.Count + 1)

  'Change the text of the first text box on the slide.
  ActivePresentation.Slides(ActivePresentation.Slides.Count).Shapes(1).TextFrame.TextRange.Text = WS.Cells(i, 1).Value
Next
End Sub

Error:

Run-time error '429': ActiveX component can't create object

On debugging, it's highlighting the text

Set OWB = Excel.Application.Workbooks.Open(Filename:=":Users:vikshek:Desktop:list.xlsx")
  • Copy your code into the question and then highlight it and use the "code" ({}) button in the editor to mark it as code, this will fix the formatting. – Ƭᴇcʜιᴇ007 Aug 14 '16 at 14:41
  • @Ƭᴇcʜιᴇ007 That link might help, but note that it's about Office 2003 and Vikram's trying to get this working on a Mac. Vikram, as far as I know, COM automation (what you're trying to do) is only supported in Windows Office. You'll probably need to use Applescript instead. Check Ron DeBruin's site for lots of good Mac/VBA workarounds: rondebruin.nl – Steve Rindsberg Aug 16 '16 at 15:25
1

The path name must include the volume name. Try the complete path name for the file, for example:

Set OWB = Excel.Application.Workbooks.Open(Filename:="Macintosh HD:Users:vikshek:Desktop:list.xlsx")`

Try the POSIX path name of the file which does not need the volume name, although this form may not work before Excel 2013.

/Users/vikshek/Desktop/list.xlsx

Reference

See Performing File and Folder Operations Programmatically in Excel 2011 for the Mac for examples using Applescript (with the MacScript function) and VBA.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.