VBA Coding

ankit4mi

New Member
Joined
Apr 28, 2021
Messages
8
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi,

I have the below windows macro which runs perfectly in windows. I want to run the same macro in MAC. Can someone help me in editing the macro so that it can in MAC Pc's also.

Sub subtoWord()
Range("D2:D33").Select
Selection.Copy
Dim objWord As Word.Application
Set objWord = CreateObject("Word.Application")
With objWord
.Documents.Add
.Visible = True
.Selection.Paste

MsgBox "Your tables have successfully been exported to a new Word document."

End With
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
This macro is not running in MAC. as it gives Automation error or Out of memory Error.
Did you try the link? I do not have access to anything running macos, so I really cannot help except to point you to other potential solutions. In the future, it is also helpful to post exactly what your error is and which line it occurs on - otherwise the people helping you just have to guess.

These answers seem to point to error handling in case an instance of Word is already open, so maybe check that out:
 
Upvote 0
Hi,

On the below code it given me Automation error on Set wdApp = CreateObject("Word.application") line. I am trying to run this code on MAC platform. Can you please help in running this code successfully.

Sub subtoWord()
Range("D2:D33").Select
Selection.Copy

Dim wdApp As Object
Dim wdDoc As Object
Set wdApp = CreateObject("Word.application")
wdApp.Visible = True
wdApp.DisplayAlerts = False
With wdApp
.Documents.Add
.Visible = True
.Selection.Paste

MsgBox "Your tables have successfully been exported to a new Word document."

End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,479
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top