View Single Post
  #6  
Old March 3rd 07, 03:41 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Macro works in Word 2007, but not in Outlook 2007


What line causes that error?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)


Am Sat, 3 Mar 2007 04:10:05 -0800 schrieb LesG:

Hi Michael

thanx for the tips. I found the Word's object library reference OK. But i
have trouble with the rest; this is what I did and now i get a "Run time
error 438. Object doesn't support this property or method". Anyway, this

is
the first part of the macro:
(and thank you for your patience with me :-)

Sub Magyar()
'
' Magyar Macro
' Macro recorded 29/09/00 by LGaram
'
Dim wdSelection As Word.Selection
Dim wdDoc As Word.Document

Set wdDoc = Application.ActiveInspector.CurrentItem.WordEditor
Set wdSelection = wdDoc.ActiveWindow.Selection

wdSelection.Find.ClearFormatting
wdSelection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "aa"
.Replacement.Text = "á"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With



"Michael Bauer [MVP - Outlook]" wrote:



Yes, that's what I meant. For sure, that code never ran in Outlook :-)

You might try the following: Add a reference to Word's object library, in
Outlook via Tools/References. Then replace "Selection" by wdSelection and
insert a few lines at the beginning:

Dim wdSelection As Word.Selection
Dim wdDoc as Word.Document

Set wdDoc=Application.ActiveInspector.CurrentItem.Word Editor
Set wdSelection=wdDoc.ActiveWindow.Selection

That should give you the selection of the currently opened e-mail.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)

Am Fri, 2 Mar 2007 02:48:25 -0800 schrieb LesG:

Hi Michael,
thank you for your reply. It highlights the line:
"Selection.Find.ClearFormatting" and then "With Selection.Find"
As I mentioned, it works perfectly fine in Word.
I hope this is what you mean by showing the code:

Sub Magyar()
'
' Magyar Macro
' Macro recorded 29/09/00 by LGaram
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "aa"
.Replacement.Text = "á"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ee"
.Replacement.Text = "é"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ii"
.Replacement.Text = "í"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "oo"
.Replacement.Text = "ó"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "uu"
.Replacement.Text = "ú"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "o:"
.Replacement.Text = "ö"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "u:"
.Replacement.Text = "ü"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "o"""
.Replacement.Text = "ô"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "u"""
.Replacement.Text = "û"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub


"Michael Bauer [MVP - Outlook]" wrote:



Please show the code and the line that raises the error.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?...4&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)

Am Thu, 1 Mar 2007 22:50:00 -0800 schrieb LesG:

For years I used a macro in Outlook Xp which I recorded in Word XP. I
think
it had something to do with th fact that in that program Word was my

email
editor.
The same macro now works in Word 2007 as it should, but when I try to

run
it
in Outlook 2007 I get a "Runtime error 424. Object required" error
warning.
I have never written a macro, I merely recorded the last one, so

please
be
gently with me in your reply :-)

Regards; Les


Ads