vba in outlook 2007

Status
Not open for further replies.
M

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
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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

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
 
M

mahesh

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 " 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
>

>

> 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

> .
>
 
M

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 " 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
> >

> >

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

> > .
> >
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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

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 " 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
> >>

> >>

>>
>>
>>> 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
> >> .
> >>
 
M

mahesh

Thank you. Will try it out.

"Michael Bauer " 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
>

>

> 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 " 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
> >>>

> >>>

> >>
> >>
> >>> 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
> >>> .
> >>>

> .
>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Outlook 2007 Email Categorization using VBA Outlook VBA and Custom Forms 1
Peter H Williams VBA & Outlook 2007 Using Outlook 3
J Outlook 2007 Rules & VBA: How to run a script on a report message (ReportItem) Using Outlook 14
O For Outlook 2007 - VBA to print attachments Using Outlook 1
M Updating VBA code from outlook 2007 to outlook 2010 Using Outlook 1
J Creating Tasks in Outlook 2007 with VBA Outlook VBA and Custom Forms 1
L List of Calender Fields for VBA (Outlook 2007) Outlook VBA and Custom Forms 1
R Outlook 2003/2007 Rule and Conditions for InBox VBA customization Outlook VBA and Custom Forms 3
E Outlook 365 Outlook/VBA Outlook VBA and Custom Forms 11
J VBA for outlook to compare and sync between calendar Outlook VBA and Custom Forms 1
E Outlook VBA change GetDefaultFolder dynamically Outlook VBA and Custom Forms 6
S vba outlook search string with special characters Outlook VBA and Custom Forms 1
U Outlook 2019 VBA run-time error 424 Outlook VBA and Custom Forms 2
G VBA to save selected Outlook msg with new name in selected network Windows folder Outlook VBA and Custom Forms 1
F Excel VBA to move mails for outlook 365 on secondary mail account Outlook VBA and Custom Forms 1
K Outlook Office 365 VBA download attachment Outlook VBA and Custom Forms 2
V vBA for searching a cell's contents in Outlook and retrieving the subject line Outlook VBA and Custom Forms 1
B vBA for exporting excel file from outlook 2016 Outlook VBA and Custom Forms 3
S Excel vba code to manage outlook web app Using Outlook 10
H Custom Outlook Contact Form VBA Outlook VBA and Custom Forms 1
S Problem Checking the available stores in my Inbox (Outlook VBA) Outlook VBA and Custom Forms 0
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
O VBA Outlook Message Attachment - Array Index Out of Bounds Outlook VBA and Custom Forms 0
J Want to learn VBA Macros for Outlook. What book can you recommend? Outlook VBA and Custom Forms 2
M Outlook 2013 reminder email by using Outlook vba Outlook VBA and Custom Forms 2
D Outlook VBA error extracting property data from GetRules collection Outlook VBA and Custom Forms 10
O Email not leaving Outbox when using Excel VBA to sync Outlook account Outlook VBA and Custom Forms 4
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
B Outlook Business Contact Manager with SQL to Excel, User Defined Fields in BCM don't sync in SQL. Can I use VBA code to copy 1 field to another? BCM (Business Contact Manager) 0
N How can I increase/faster outlook VBA Macro Speed ? Using Outlook 2
N Outlook Email Rule execution through shortcut keys (VBA codes) Using Outlook 1
A VBA Code in Outlook disappears after first use Outlook VBA and Custom Forms 1
dweller Outlook 2010 Rule Ignores VBA Script Outlook VBA and Custom Forms 2
G Outlook VBA and Google Calendar ("Events") Outlook VBA and Custom Forms 1
J VBA Outlook : Subject line : Cut and Paste name to heading , number to very end of the body of Email Outlook VBA and Custom Forms 1
B Advanced Search in MS Outlook by VBA and SQL Outlook VBA and Custom Forms 2
K Outlook Archive to PST Files by Date Range VBA Script? Outlook VBA and Custom Forms 1
J Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite Outlook VBA and Custom Forms 9
S Find a cell value in excel using outlook vba Using Outlook 1
J Execute Add-In Button from VBA Outlook 2016 Outlook VBA and Custom Forms 1
J Open an outlook email by Subject on MS Access linked table with VBA Outlook VBA and Custom Forms 10
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
M Slow VBA macro in Outlook Outlook VBA and Custom Forms 5
T Outlook AntiSpam with VBA Outlook VBA and Custom Forms 1
F "Move to" O365 feature to Outlook client via VBA Outlook VBA and Custom Forms 4
B query outlook using vba Outlook VBA and Custom Forms 13
J VBA to switch Outlook online/offline Outlook VBA and Custom Forms 4
M VBA to change flag status in outlook contact item Outlook VBA and Custom Forms 3
T VBA outlook, detect priority emails Outlook VBA and Custom Forms 5
C Need VBA code to automatically save message outside outlook and add date Outlook VBA and Custom Forms 1

Similar threads

Top