A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

vba in outlook 2007



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 8th 10, 08:06 AM posted to microsoft.public.outlook.program_vba
Mahesh
external usenet poster
 
Posts: 12
Default vba in outlook 2007

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  
Old January 8th 10, 09:35 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default vba in outlook 2007


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  
Old January 11th 10, 08:44 AM posted to microsoft.public.outlook.program_vba
Mahesh
external usenet poster
 
Posts: 12
Default vba in outlook 2007

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  
Old January 12th 10, 05:52 AM posted to microsoft.public.outlook.program_vba
Mahesh
external usenet poster
 
Posts: 12
Default vba in outlook 2007

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  
Old January 12th 10, 08:15 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default vba in outlook 2007



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  
Old January 14th 10, 09:18 AM posted to microsoft.public.outlook.program_vba
Mahesh
external usenet poster
 
Posts: 12
Default vba in outlook 2007

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 05:49 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.