Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Applications / Word / May 2008



Tip: Looking for answers? Try searching our database.

Convert Macros for use with Mac?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tony - 06 May 2008 17:54 GMT
Hi All,

I'll start by saying that I have no experience with Macs, so please be
patient with me...

I've got a Word template that we've pushed out to some of our vendors that
runs a few macros when a new document based on the template is created.  Up
until this point we've only had to roll it out to vendors using PCs but now
we have a vendor in a Mac environment who can't use the template.  The
vendor creates a new document from the template, is prompted to allow or
disallow macros (he allows them in this instance), and the document is
created but the macros do not run.  So, I'm assuming that:

1) The vba code will not work at all
2) I need to tweak the code to work with Word for Mac

In either case, I'm not sure where to start and hope someone can point me in
the correct direction.  Thanks in advance for any help you can offer.

Tony
CyberTaz - 06 May 2008 22:26 GMT
Hi Tom -

I don't have all the answers, but at least I can let you know what those who
*can* answer will need to know:-)

First, if the users are running Word 2008 your first assumption is correct -
Office 2008 does NOT support any version of VBA, so the macros won't run. My
gut reaction is that this is the case here. If so, AppleScript to replace
the code may be an option. OTOH...

If they're using Word 2004 or prior your code will have to be tweaked but it
should run. Mac Office is approximately 1 version behind in VBA, so if the
code was written in a more recent version than what's used on Macs the
differences may cause it to not run at all. That's the part I can't answer
for you, but there are other regulars in the group who can.

They'll need to know Mac Word/Office versions, VBA versions and probably a
copy of the code itself.

Regards |:>)
Bob Jones
[MVP] Office:Mac

On 5/6/08 12:54 PM, in article OHQvWn5rIHA.672@TK2MSFTNGP02.phx.gbl, "Tony"
<|toxendine@hoopercorp.com|> wrote:

> Hi All,
>
[quoted text clipped - 16 lines]
>
> Tony
John McGhie - 07 May 2008 01:32 GMT
Hi Tony:

The fact that he is getting the Enable Macros prompt indicates that he has a
version of Mac Office that still contains the VBA Interpreter: so he is at
Word 2004 or earlier.

In Word 2008, VBA code will be silently ignored, because there is no VBA
runtime in Office 2008.

VBA in Office Mac has not advanced beyond VBA 5.  So you need to dust off a
copy of Word 2000 and compile there: anything that won't compile in Word
2000, will not compile on a Mac.

The general idea is to surround the stuff that won't compile with "Hash
Defines".  These are compiler directives that tell the Mac compiler to
compile a different set of statements to the PC compiler.

Syntax
#If expression Then
   statements
[#ElseIf expression-n Then
   [elseifstatements]]
[#Else
   [elsestatements]]
#End If

For example:

   #If Mac Then
     .Protect Password:="", NoReset:=False, Type:=wdNoProtection
   #Else
   .Protect Password:="", NoReset:=False, Type:=wdNoProtection, _
        UseIRM:=False, EnforceStyleLock:=True
   #End If

If I were you, I would put all of your hash-defines in a separate module,
because you will have to tweak them for each new version of Mac Office and
PC Office :-)

You also need to explain to your vendor that if they remove Office 2004,
your template will be instantly disabled, and there is nothing you can do
about that.

So they need to remain on Office 2004 for Mac, or install a PC :-)

For more information, send me an email at john@mcghie.name and we'll take
this offline.  Note:  HTML email or attachments are unlikely to survive the
spam filter :-)

Cheers

On 7/05/08 2:54 AM, in article OHQvWn5rIHA.672@TK2MSFTNGP02.phx.gbl, "Tony"
<|toxendine@hoopercorp.com|> wrote:

> Hi All,
>
[quoted text clipped - 16 lines]
>
> Tony

Signature

Don't wait for your answer, click here: http://www.word.mvps.org/

Please reply in the group.  Please do NOT email me unless I ask you to.

John McGhie, Microsoft MVP, Word and Word:Mac
Sydney, Australia.   mailto:john@mcghie.name

CyberTaz - 07 May 2008 11:30 GMT
Hi John -

<snip>
On 5/6/08 8:32 PM, in article C44735D0.131F8%john@mcghie.name, "John McGhie"
<john@mcghie.name> wrote:

> The fact that he is getting the Enable Macros prompt indicates that he has a
> version of Mac Office that still contains the VBA Interpreter: so he is at
> Word 2004 or earlier.
<snip>

Depends on the exact wording of the message - which wasn't explicitly
stated:-)

Macro documents (.docm) do open directly and produce no message at all.
However, opening a .dotm or generating a new .docx based on a .dotm does,
indeed, produce a mess asking whether to "Open & Remove Macros" or simply
"Open" - even the latter case renders the macro(s) neutered, of course.

AFAIK, that message cannot be disabled, whereas the warning in 2004 can be
turned off in the Security Prefs. That's why I "leaned" in that direction:-)

Regards |:>)
Bob Jones
[MVP] Office:Mac
John McGhie - 07 May 2008 12:41 GMT
Yes, you are quite correct: but the 2008 choice is "Open and Remove" or just
"Open".  If you get an "Allow or Disallow" choice, you're in 2004 and it's
trying to run them :-)

So I lean the other way: he's in 2004 and the wheels won't really fall off
until he decides to "upgrade" :-)

Cheers

On 7/05/08 8:30 PM, in article C446FCFA.29E48%onlygeneraltaz1@com.cast.net,

> Hi John -
>
[quoted text clipped - 21 lines]
> Bob Jones
> [MVP] Office:Mac

Signature

Don't wait for your answer, click here: http://www.word.mvps.org/

Please reply in the group.  Please do NOT email me unless I ask you to.

John McGhie, Microsoft MVP, Word and Word:Mac
Sydney, Australia.   mailto:john@mcghie.name

CyberTaz - 07 May 2008 13:11 GMT
Then we're in total agreement whether you like it or not you old goat - we
need to have version information in order to offer accurate replies:-)

Regards |:>)
Bob Jones
[MVP] Office:Mac

On 5/7/08 7:41 AM, in article C447D27A.148AF%john@mcghie.name, "John McGhie"
<john@mcghie.name> wrote:

> Yes, you are quite correct: but the 2008 choice is "Open and Remove" or just
> "Open".  If you get an "Allow or Disallow" choice, you're in 2004 and it's
[quoted text clipped - 32 lines]
>> Bob Jones
>> [MVP] Office:Mac
John McGhie - 08 May 2008 04:45 GMT
Oh, hell, he's outed me...

I resemble that remark :-)

On 7/05/08 10:11 PM, in article C44714CE.3A49E%onlygeneraltaz1@com.cast.net,

> Then we're in total agreement whether you like it or not you old goat - we
> need to have version information in order to offer accurate replies:-)
>
> Regards |:>)
> Bob Jones
> [MVP] Office:Mac

Signature

Don't wait for your answer, click here: http://www.word.mvps.org/

Please reply in the group.  Please do NOT email me unless I ask you to.

John McGhie, Microsoft MVP, Word and Word:Mac
Sydney, Australia.   mailto:john@mcghie.name

Tony - 07 May 2008 15:26 GMT
OK Guys, if I understand you correctly, verifying the version of Word the
user has is the first step.  2004 Or earlier & I can make something work by
tweaking the code appropriately and compiling in Word 2000.  2008 And all
bets are off.

Here's the code that's running; it's very simple but I have no idea how to
tweak it appropriately but will check out the Mac MVP site.  Any suggestions
are appreciated, of course...

There are a couple of fields, each of which I'd like to prepopulate when a
new doc is open, to generate 'unique' information to identify new docs as
they come back to us.

//CODE START//

Private Sub Document_New()
On Error GoTo Err_Document_New

   ActiveDocument.FormFields("txtTestDate").Result = Format(Now(),
"m/d/yy")
   ActiveDocument.Bookmarks("txtTestDate").Range.Fields(1).Locked = True

   ActiveDocument.FormFields("txtPoNumber").Result = "SKAR" & Format(Now(),
"HhNnSs")
   ActiveDocument.Bookmarks("txtPoNumber").Range.Fields(1).Locked = True

Exit_Document_New:
   Exit Sub

Err_Document_New:
   MsgBox Err.Description
   Resume Exit_Document_New

End Sub

//CODE END//

Thanks for the feedback and assistance.  I appreciate the help.

Ciao,

Tony
John McGhie - 08 May 2008 05:01 GMT
In Word 2008, there are no bets, because there is no betting shop :-)

Much better:  Tell the CUSTOMER to compile, in Mac Word.

1)  Open your template using Word>File>Open.

2)  If you double-clicked, start again.

3)  Open the VBA Editor by hitting Option + F11.

4)  On the Debug menu choose "Compile Project".

5)  Copy any lines that go Yellow and send to ...

For the sample below: I've done it for you.  There's nothing wrong with the
code you sent in Mac Word 2004, clean compile.  Better than my code... :-)

But I would query the use of ActiveDocument.  You know damn well that is
never safe in End User Land... {Hang your head in shame!!}  Return the new
document as an object and store it as a variable.  Then access the document
by variable name.

Chances are he's running it on a blank document that was not created from
your template and thus it has no user forms in it :-)

When crossing the yawning gulf from the Dark Side, you need to understand
that Mac Users are running on Unix.  They reboot their computers only when
the electricity goes off, and they re-start Word once a month, whether it
needs it or not...

Until Office 2008, of course, which is fully Office PC compliant: it won't
run that long without blowing up :-)

Cheers

On 8/05/08 12:26 AM, in article #UXzf5EsIHA.5096@TK2MSFTNGP02.phx.gbl,

> OK Guys, if I understand you correctly, verifying the version of Word the
> user has is the first step.  2004 Or earlier & I can make something work by
[quoted text clipped - 38 lines]
>
> Tony

Signature

Don't wait for your answer, click here: http://www.word.mvps.org/

Please reply in the group.  Please do NOT email me unless I ask you to.

John McGhie, Microsoft MVP, Word and Word:Mac
Sydney, Australia.   mailto:john@mcghie.name

Tony - 08 May 2008 16:39 GMT
John,

Thanks again for the reply.  I'll ask them to compile on the Mac and see how
things go.  I'll look at getting rid of the ActiveDocument reference, as
well.

Again, I really appreciate the help.  Due to the nature of our business, we
very rarely work with Mac shops, so in a way this is good, as I'm getting a
little education...

Ciao,

Tony

> In Word 2008, there are no bets, because there is no betting shop :-)
>
[quoted text clipped - 82 lines]
>>
>> Tony
Tony - 08 May 2008 16:40 GMT
One more thing... it's 2004 that the end user is using.

> OK Guys, if I understand you correctly, verifying the version of Word the
> user has is the first step.  2004 Or earlier & I can make something work
[quoted text clipped - 38 lines]
>
> Tony
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.