Need Help Converting VBA from Windows to Mac

Daniellel

Board Regular
Joined
Jun 21, 2011
Messages
242
Hi, I am still self learning VBA code on Windows but i now need it to work on a mac! I have some code that basically copies a set area from excel and pastes it into word as a picture (it does it as many times as there are columns in another tab)
I have it working perfectly on Windows but can not get it to work for mac? I have managed to get it to at least open a word file on the mac now but all it does is paste blank pictures and not the actual selection from excel... My main issue is that i dont actually have a mac so i can not test that it is working, i have to keep sending it back and asking if it worked :( Please help!

Windows Code:
VBA Code:
        ''''Create Word
Dim objWord, objDoc As Object
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
With objDoc.PageSetup
    .Orientation = wdOrientLandscape
    
End With
    
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''Start Task

'SetUp
Dim cab As Long
Dim dab As Long
Sheet21.Select
cab = Cells(1, Columns.Count).End(xlToLeft).Column
For dab = 1 To cab

'Action
Sheet21.Select
ActiveSheet.Range(Cells(1, dab), Cells(20, dab)).Select
Selection.Copy
Sheet2.Select
Sheet2.Range("L10").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

'Copy To Word
Sheet2.Select
On Error Resume Next
Range("Print_Area50").CopyPicture Appearance:=xlScreen, Format:=xlPicture
objWord.Visible = True
objWord.Selection.Paste
objWord.Selection.TypeParagraph

'Next Task
Next dab

This is what i have so far for the mac:
VBA Code:
        ''''Create Word
Dim oWord As Object
Set oWord = CreateObject(Class:=("Word.application"))
oWord.Visible = True
oWord.Activate
Dim oDoc
Set oDoc = oWord.Documents.Add


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''Start Task

'SetUp
Dim cab As Long
Dim dab As Long
Sheet21.Select
cab = Cells(1, Columns.Count).End(xlToLeft).Column
For dab = 1 To cab

Sheet21.Select
ActiveSheet.Range(Cells(1, dab), Cells(20, dab)).Select
Selection.Copy
Sheet2.Select
Sheet2.Range("L10").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

'Copy To Word
Sheet21.Select
On Error Resume Next
Range("Print_Area50").CopyPicture
oWord.Aapplication
oWord.Application.Selection.PasteSpecial Link:=False, DataType:=15, _
        DisplayAsIcon:=False
oWord.Selection.TypeParagraph

'Next Task
Next dab
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Does it work if you do it manually? You can record it as a Mac OS macro. Then you can issue that macro from a VBA macro:
VBA Code:
MacScript("your MacOS macro string here")
MacScript("return POSIX path of (path to desktop folder) as string") 'example

I am no expert on this. Check the website of Ron de Bruin, he may have some pointers
 
Upvote 0

Forum statistics

Threads
1,214,958
Messages
6,122,475
Members
449,087
Latest member
RExcelSearch

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