Hi,
I believe this is an old script of yours that I have been using,
Print MultiEnvelope based on
Print MultiEnvelope from E in W, v 1.0
Copyright © 2000 George Clark <mailto:
[email protected]>
Some portions inspired by/altered due to input from Omar Shahine and
David Cortright
It has been great in Office 2001 and X, but now I get an error in
Office 2004.
When it runs, it stops and says:
Microsoft Word got an error: Can't continue «event MSWDactv».
In the script it says, twice, something about MSWDactv
tell application "Microsoft Word"
«event MSWDactv»
make new document
end tell
tell application "Microsoft Word"
«event MSWDactv»
do Visual Basic vbScript
end tell
I'm assuming that the new 2004 doesn't understand MSWDactv anymore.
What should I change it to? I'm not sure what it means to start with
and I can't locate the former Applescript dictionary for MSWord to look
it up. And I'm not very familiar with Applescript to be certain that
is the problem. Can you help me out?
I'm running Office 2004 with Mac OS 10.3.9 and below i have pasted the
entire script.
----------------------------------------
property useBarcode : "Yes"
property useTitle : "No"
property useSuffix : "No"
property useJobTitle : "No"
(*
Valid settings for the above four properties are "Yes", or anything
else. If "Yes"
the item is included on the envelope. If anything else, it is not
included
*)
property returnAddress : "Ask"
property deliveryAddress : "Ask"
(*
Valid settings for the above two items are "Ask", "Default" or "Work".
"Ask" will
ask each time you run the script which address to use for your return
address, or
for the delivery address (respectively). If set to "Default", whatever
is the
default address is used. When set to "Work", the Work address is always
used. Any
other setting will force the use of the Home address
*)
global userAddress
global userCountry
global counter
set counter to 0
tell application "Microsoft Entourage"
activate
try
set theSelection to selection
set temp to item 1 of theSelection
on error
my Error_Message()
return
end try
if class of temp is not contact and class of temp is not group then
my Error_Message()
return
else if deliveryAddress is "Ask" then
set addchoice to (button returned of (display dialog ¬
"Use Default, Home or Work address of the contact?" buttons
{"Default", "Home", "Work"} ¬
default button "Default"))
else
set addchoice to deliveryAddress
end if
if returnAddress is "Ask" then
set rtnAdd to (button returned of (display dialog ¬
"Use your Home or Work address as the Return Address?" buttons
{"Home", "Work"} ¬
default button (default postal address of me contact as string)))
else if returnAddress is "Default" then
set rtnAdd to (default postal address of me contact as string)
else
set rtnAdd to returnAddress
end if
if rtnAdd is "Work" then
set rtnAdd to business address of me contact
set userDept to department of me contact
set userCompany to company of me contact
else
set rtnAdd to home address of me contact
set userDept to ""
set userCompany to ""
end if
set userAddress to (first name of me contact) & " " & (last name of me
contact) & return
if userDept is not "" then set userAddress to userAddress & userDept &
return
if userCompany is not "" then set userAddress to userAddress &
userCompany & return
set userAddress to userAddress & street address of rtnAdd & return
set userAddress to userAddress & city of rtnAdd
if (state of rtnAdd) is not "" then
set userAddress to userAddress & ", " & state of rtnAdd
end if
if (zip of rtnAdd) is not "" then
set userAddress to userAddress & " " & zip of rtnAdd
end if
set userCountry to country of rtnAdd
end tell
tell application "Microsoft Word"
«event MSWDactv»
make new document
end tell
tell application "Microsoft Entourage"
repeat with theItem in theSelection
if class of theItem is contact then
if addchoice is "Default" then
set thisadd to (default postal address of theItem as string)
else
set thisadd to addchoice
end if
my Process_Contact(theItem, thisadd)
else if class of theItem is group then
set grouplist to every group entry of theItem
repeat with gmember in grouplist
set temp to (address of content) of gmember
set theContact to find temp
if theContact is not {} then
set theContact to item 1 of theContact
if addchoice is "Default" then
set thisadd to (default postal address of theContact as string)
else
set thisadd to addchoice
end if
my Process_Contact(theContact, thisadd)
end if
end repeat
end if
end repeat
end tell
tell application "Microsoft Word" to close front document without
saving
tell application "Microsoft Entourage"
activate
if counter = 0 then
display dialog ¬
"No envelopes were printed because no valid addresses were found"
buttons {"Okay"} default button "Okay"
end if
end tell
on Process_Contact(whichc, whicha)
global counter
tell application "Microsoft Entourage"
set theName to first name of whichc
set temp to last name of whichc
if temp is not "" then
if theName is "" then
set theName to temp
else
set theName to theName & " " & temp
end if
end if
if theName is not "" then
set jobTitle to ""
if whicha is "home" then
set a to home address of whichc
set dept to ""
set co to ""
else
set a to business address of whichc
set dept to department of whichc
set co to company of whichc
if useJobTitle is "Yes" then set jobTitle to job title of whichc
end if
set theStreetAddress to street address of a
set theCity to city of a
if theStreetAddress is not "" and theCity is not "" then
set theState to state of a
set theZip to zip of a
set theCountry to country of a
if useTitle is "Yes" then
set temp to title of whichc
if temp is not "" then set theName to temp & " " & theName
end if
if useSuffix is "Yes" then
set temp to suffix of whichc
if temp is not "" then set theName to theName & ", " & temp
end if
end if
else
set theStreetAddress to ""
set theCity to ""
end if
end tell
if theStreetAddress is not "" and theCity is not "" then
set counter to counter + 1
set tempReturn to userAddress
if jobTitle is not "" then set theName to theName & ", " & jobTitle
set theAddress to theName & return
if dept is not "" then set theAddress to theAddress & dept & return
if co is not "" then set theAddress to theAddress & co & return
set theAddress to theAddress & theStreetAddress & return
set theAddress to theAddress & theCity
if theState is not "" then set theAddress to theAddress & ", " &
theState
if theZip is not "" then set theAddress to theAddress & " " & theZip
if theCountry is not "" then
if theCountry ≠userCountry then
set theAddress to theAddress & return & theCountry
set tempReturn to tempReturn & return & userCountry
end if
end if
set vbScript to "recep = " & my Process_for_VB(theAddress)
set vbScript to vbScript & "retaddr = " & my
Process_for_VB(tempReturn)
set vbScript to vbScript & "ActiveDocument.Envelope.PrintOut
Address:=recep, _
ReturnAddress:=retaddr, PrintBarCode:="
if useBarcode is "Yes" then
set vbScript to vbScript & "True"
else
set vbScript to vbScript & "False"
end if
tell application "Microsoft Word"
«event MSWDactv»
do Visual Basic vbScript
end tell
end if
end Process_Contact
on Process_for_VB(theString)
set i to 0
set finalString to ""
repeat
set i to i + 1
try
set temp to paragraph i of theString
set temp1 to "\"" & temp & "\""
set finalString to finalString & temp1
if temp = paragraph -1 of theString then
set finalString to finalString & return
else
set finalString to finalString & " & vbCr & "
end if
on error
exit repeat
end try
end repeat
return finalString
end Process_for_VB
on Error_Message()
tell application "Microsoft Entourage"
display dialog ¬
"Please select one or more contacts or groups in your address book"
buttons {"Okay"} default button "Okay"
end tell
end Error_Message