![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Dear Gurus,
Im getting the following error when i run my vba macro in outlook 2007. Earlier this macro was successfully running in outlook 2003. I've just migrated from outlook 2003 to outlook 2007 The error message : Compile error: User-defined type not defined at the following line: Dim oStory As Range Pls advice, Thanks.. Mahesh |
Ads |
#2
|
|||
|
|||
![]() The Outlook oject model doesn't know a Range object. It's always a good idea to use the full object name, for instance Word.Range, or Excel.Range. So, check the code and see what library the Range object belongs to, then add a ref on it via Tools/References. -- Best regards Michael Bauer - MVP Outlook Manage and share your categories: http://www.vboffice.net/product.html?pub=6&lang=en Am Fri, 8 Jan 2010 00:06:01 -0800 schrieb mahesh: Dear Gurus, Im getting the following error when i run my vba macro in outlook 2007. Earlier this macro was successfully running in outlook 2003. I've just migrated from outlook 2003 to outlook 2007 The error message : Compile error: User-defined type not defined at the following line: Dim oStory As Range Pls advice, Thanks.. Mahesh |
#3
|
|||
|
|||
![]()
Hi Michael,
I proceeded to include the Tools/Reference for Word,Excel,VBA etc... I now get the following error when i execute the macro in Office 2007: Run-time error '429': ActiveX component can't create object I then click Debug at the Msgbox Further, when i put the cursor on the following line: For Each rngStory In ActiveDocument.StoryRanges it displays this tooltip error that reads: ActiveDocument.StoryRanges=Object Variable or With Block variable not set Following is the code im trying to execute: Sub a2() Dim rngStory As Word.Range For Each rngStory In ActiveDocument.StoryRanges With rngStory.Find .Text = "find text" .Replacement.Text = "I'm found" .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next rngStory End Sub Am i btw missing any other references. Thanks, Mahesh "Michael Bauer [MVP - Outlook]" wrote: The Outlook oject model doesn't know a Range object. It's always a good idea to use the full object name, for instance Word.Range, or Excel.Range. So, check the code and see what library the Range object belongs to, then add a ref on it via Tools/References. -- Best regards Michael Bauer - MVP Outlook Manage and share your categories: http://www.vboffice.net/product.html?pub=6&lang=en Am Fri, 8 Jan 2010 00:06:01 -0800 schrieb mahesh: Dear Gurus, Im getting the following error when i run my vba macro in outlook 2007. Earlier this macro was successfully running in outlook 2003. I've just migrated from outlook 2003 to outlook 2007 The error message : Compile error: User-defined type not defined at the following line: Dim oStory As Range Pls advice, Thanks.. Mahesh . |
#4
|
|||
|
|||
![]()
Sorry, THere was a typo in the above...
ITs NOT word.range Its just Range Sub a2() Dim rngStory As Range For Each rngStory In ActiveDocument.StoryRanges With rngStory.Find .Text = "find text" .Replacement.Text = "I'm found" .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next rngStory End Sub Does outlook 2007 recognize Range command? Thanks.. "mahesh" wrote: Hi Michael, I proceeded to include the Tools/Reference for Word,Excel,VBA etc... I now get the following error when i execute the macro in Office 2007: Run-time error '429': ActiveX component can't create object I then click Debug at the Msgbox Further, when i put the cursor on the following line: For Each rngStory In ActiveDocument.StoryRanges it displays this tooltip error that reads: ActiveDocument.StoryRanges=Object Variable or With Block variable not set Following is the code im trying to execute: Sub a2() Dim rngStory As Word.Range For Each rngStory In ActiveDocument.StoryRanges With rngStory.Find .Text = "find text" .Replacement.Text = "I'm found" .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next rngStory End Sub Am i btw missing any other references. Thanks, Mahesh "Michael Bauer [MVP - Outlook]" wrote: The Outlook oject model doesn't know a Range object. It's always a good idea to use the full object name, for instance Word.Range, or Excel.Range. So, check the code and see what library the Range object belongs to, then add a ref on it via Tools/References. -- Best regards Michael Bauer - MVP Outlook Manage and share your categories: http://www.vboffice.net/product.html?pub=6&lang=en Am Fri, 8 Jan 2010 00:06:01 -0800 schrieb mahesh: Dear Gurus, Im getting the following error when i run my vba macro in outlook 2007. Earlier this macro was successfully running in outlook 2003. I've just migrated from outlook 2003 to outlook 2007 The error message : Compile error: User-defined type not defined at the following line: Dim oStory As Range Pls advice, Thanks.. Mahesh . |
#5
|
|||
|
|||
![]() With the ActiveDocument object it becomes clear that it's Word not Excel. You get the error because ActiveDocument is nothing. Create a variable for it, and if the code is for an opened email, set the variable to Application.ActiveInspector.WordEditor, which returns a Word.Document object. -- Best regards Michael Bauer - MVP Outlook Manage and share your categories: http://www.vboffice.net/product.html?pub=6&lang=en Am Mon, 11 Jan 2010 21:52:01 -0800 schrieb mahesh: Sorry, THere was a typo in the above... ITs NOT word.range Its just Range Sub a2() Dim rngStory As Range For Each rngStory In ActiveDocument.StoryRanges With rngStory.Find .Text = "find text" .Replacement.Text = "I'm found" .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next rngStory End Sub Does outlook 2007 recognize Range command? Thanks.. "mahesh" wrote: Hi Michael, I proceeded to include the Tools/Reference for Word,Excel,VBA etc... I now get the following error when i execute the macro in Office 2007: Run-time error '429': ActiveX component can't create object I then click Debug at the Msgbox Further, when i put the cursor on the following line: For Each rngStory In ActiveDocument.StoryRanges it displays this tooltip error that reads: ActiveDocument.StoryRanges=Object Variable or With Block variable not set Following is the code im trying to execute: Sub a2() Dim rngStory As Word.Range For Each rngStory In ActiveDocument.StoryRanges With rngStory.Find .Text = "find text" .Replacement.Text = "I'm found" .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next rngStory End Sub Am i btw missing any other references. Thanks, Mahesh "Michael Bauer [MVP - Outlook]" wrote: The Outlook oject model doesn't know a Range object. It's always a good idea to use the full object name, for instance Word.Range, or Excel.Range. So, check the code and see what library the Range object belongs to, then add a ref on it via Tools/References. -- Best regards Michael Bauer - MVP Outlook Manage and share your categories: http://www.vboffice.net/product.html?pub=6&lang=en Am Fri, 8 Jan 2010 00:06:01 -0800 schrieb mahesh: Dear Gurus, Im getting the following error when i run my vba macro in outlook 2007. Earlier this macro was successfully running in outlook 2003. I've just migrated from outlook 2003 to outlook 2007 The error message : Compile error: User-defined type not defined at the following line: Dim oStory As Range Pls advice, Thanks.. Mahesh . |
#6
|
|||
|
|||
![]()
Thank you. Will try it out.
"Michael Bauer [MVP - Outlook]" wrote: With the ActiveDocument object it becomes clear that it's Word not Excel. You get the error because ActiveDocument is nothing. Create a variable for it, and if the code is for an opened email, set the variable to Application.ActiveInspector.WordEditor, which returns a Word.Document object. -- Best regards Michael Bauer - MVP Outlook Manage and share your categories: http://www.vboffice.net/product.html?pub=6&lang=en Am Mon, 11 Jan 2010 21:52:01 -0800 schrieb mahesh: Sorry, THere was a typo in the above... ITs NOT word.range Its just Range Sub a2() Dim rngStory As Range For Each rngStory In ActiveDocument.StoryRanges With rngStory.Find .Text = "find text" .Replacement.Text = "I'm found" .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next rngStory End Sub Does outlook 2007 recognize Range command? Thanks.. "mahesh" wrote: Hi Michael, I proceeded to include the Tools/Reference for Word,Excel,VBA etc... I now get the following error when i execute the macro in Office 2007: Run-time error '429': ActiveX component can't create object I then click Debug at the Msgbox Further, when i put the cursor on the following line: For Each rngStory In ActiveDocument.StoryRanges it displays this tooltip error that reads: ActiveDocument.StoryRanges=Object Variable or With Block variable not set Following is the code im trying to execute: Sub a2() Dim rngStory As Word.Range For Each rngStory In ActiveDocument.StoryRanges With rngStory.Find .Text = "find text" .Replacement.Text = "I'm found" .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next rngStory End Sub Am i btw missing any other references. Thanks, Mahesh "Michael Bauer [MVP - Outlook]" wrote: The Outlook oject model doesn't know a Range object. It's always a good idea to use the full object name, for instance Word.Range, or Excel.Range. So, check the code and see what library the Range object belongs to, then add a ref on it via Tools/References. -- Best regards Michael Bauer - MVP Outlook Manage and share your categories: http://www.vboffice.net/product.html?pub=6&lang=en Am Fri, 8 Jan 2010 00:06:01 -0800 schrieb mahesh: Dear Gurus, Im getting the following error when i run my vba macro in outlook 2007. Earlier this macro was successfully running in outlook 2003. I've just migrated from outlook 2003 to outlook 2007 The error message : Compile error: User-defined type not defined at the following line: Dim oStory As Range Pls advice, Thanks.. Mahesh . . |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
After Office 2007 SP2 install - Outlook 2007 macro no longer worki | rpratikno | Outlook and VBA | 13 | June 17th 09 06:19 PM |
Outlook 2007 no longer installed after SP2 2007 Office Suites upda | PGP | Outlook - Installation | 2 | May 1st 09 12:16 PM |
Outlook 2007 shared calendars are lost when exchange 2007 reboot | Cris Krikkke | Outlook - Calandaring | 2 | December 14th 07 07:25 AM |
Office Standard 2007 Trial & Outlook 2007 full version | cmmsc777 | Outlook - Installation | 3 | November 7th 07 09:10 PM |
Outlook 2007 will not open SharePoint 2007 task assignment messages | ACK | Outlook - General Queries | 3 | February 16th 07 02:15 AM |