Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Error following Microsoft Article

I followed Microsoft Knowledge Base Article 213299 XL2000: For Each Loop to
Determine If an Excel Workbook is Open

When I run the code the line

Dim wb as Workbook

is highlighted and I receive an error

Compile error: User-defined type not defined

?????

The code is written exactly as written in the article. Can I fix this?

Thanks for any help

PJ


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Error following Microsoft Article

Hi PJ

I don't look at the article.(you don't need a loop)
Use this function in a normal module

Function bIsBookOpen(ByRef szBookName As String) As Boolean
' Rob Bovey
On Error Resume Next
bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function

Sub File_Open_test()
If bIsBookOpen("Test.xls") Then
MsgBox "the File is open!"
Else
MsgBox "the File is not open!"
End If
End Sub

--
Regards Ron de Bruin
http://www.rondebruin.nl


"PJ Usher" wrote in message ...
I followed Microsoft Knowledge Base Article 213299 XL2000: For Each Loop to
Determine If an Excel Workbook is Open

When I run the code the line

Dim wb as Workbook

is highlighted and I receive an error

Compile error: User-defined type not defined

?????

The code is written exactly as written in the article. Can I fix this?

Thanks for any help

PJ




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Error following Microsoft Article

You're right I don't need a loop. Thank you for this code. I tried it but
I still get an error highlighting workbooks on this line

bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)


The error is Compile error: Methond or data member not found.

PJ



"Ron de Bruin" wrote in message
...
Hi PJ

I don't look at the article.(you don't need a loop)
Use this function in a normal module

Function bIsBookOpen(ByRef szBookName As String) As Boolean
' Rob Bovey
On Error Resume Next
bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function

Sub File_Open_test()
If bIsBookOpen("Test.xls") Then
MsgBox "the File is open!"
Else
MsgBox "the File is not open!"
End If
End Sub

--
Regards Ron de Bruin
http://www.rondebruin.nl


"PJ Usher" wrote in message

...
I followed Microsoft Knowledge Base Article 213299 XL2000: For Each Loop

to
Determine If an Excel Workbook is Open

When I run the code the line

Dim wb as Workbook

is highlighted and I receive an error

Compile error: User-defined type not defined

?????

The code is written exactly as written in the article. Can I fix this?

Thanks for any help

PJ






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Error following Microsoft Article


Hi Ron

To fix the error I changed the line to excel.application.workbooks. Thank
you very much for helping me with this code.



"PJ Usher" wrote in message
...
You're right I don't need a loop. Thank you for this code. I tried it

but
I still get an error highlighting workbooks on this line

bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)


The error is Compile error: Methond or data member not found.

PJ



"Ron de Bruin" wrote in message
...
Hi PJ

I don't look at the article.(you don't need a loop)
Use this function in a normal module

Function bIsBookOpen(ByRef szBookName As String) As Boolean
' Rob Bovey
On Error Resume Next
bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function

Sub File_Open_test()
If bIsBookOpen("Test.xls") Then
MsgBox "the File is open!"
Else
MsgBox "the File is not open!"
End If
End Sub

--
Regards Ron de Bruin
http://www.rondebruin.nl


"PJ Usher" wrote in message

...
I followed Microsoft Knowledge Base Article 213299 XL2000: For Each

Loop
to
Determine If an Excel Workbook is Open

When I run the code the line

Dim wb as Workbook

is highlighted and I receive an error

Compile error: User-defined type not defined

?????

The code is written exactly as written in the article. Can I fix

this?

Thanks for any help

PJ








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Error following Microsoft Article

In the VBE in tools = references, do you have a reference to the Excel
library?

You are doing this in Excel itself; correct?
--
Regards,
Tom Ogilvy

"PJ Usher" wrote in message
...
I followed Microsoft Knowledge Base Article 213299 XL2000: For Each Loop

to
Determine If an Excel Workbook is Open

When I run the code the line

Dim wb as Workbook

is highlighted and I receive an error

Compile error: User-defined type not defined

?????

The code is written exactly as written in the article. Can I fix this?

Thanks for any help

PJ






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Error following Microsoft Article

I'm actually doing this from MS Word but have the Microsoft Excel 9.0 Object
Library referenced.
Am I in the wrong newsgroup?

PJ


"Tom Ogilvy" wrote in message
...
In the VBE in tools = references, do you have a reference to the Excel
library?

You are doing this in Excel itself; correct?
--
Regards,
Tom Ogilvy

"PJ Usher" wrote in message
...
I followed Microsoft Knowledge Base Article 213299 XL2000: For Each

Loop
to
Determine If an Excel Workbook is Open

When I run the code the line

Dim wb as Workbook

is highlighted and I receive an error

Compile error: User-defined type not defined

?????

The code is written exactly as written in the article. Can I fix this?

Thanks for any help

PJ






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Error following Microsoft Article

Not necessarily, but if you do have a reference to that library - that is
where workbook is defined and you shouldn't get an error. In excel, the
reference in specific to the activeworkbook in the VBE IDE. I think it is
different in Word, but can't say as I don't do much in the word VBE IDE. If
the reference is set up properly, you shouldn't get the error. If you do
get the error, then I would say it isn't set up properly.


--
Regards,
Tom Ogilvy

"PJ Usher" wrote in message
...
I'm actually doing this from MS Word but have the Microsoft Excel 9.0

Object
Library referenced.
Am I in the wrong newsgroup?

PJ


"Tom Ogilvy" wrote in message
...
In the VBE in tools = references, do you have a reference to the Excel
library?

You are doing this in Excel itself; correct?
--
Regards,
Tom Ogilvy

"PJ Usher" wrote in message
...
I followed Microsoft Knowledge Base Article 213299 XL2000: For Each

Loop
to
Determine If an Excel Workbook is Open

When I run the code the line

Dim wb as Workbook

is highlighted and I receive an error

Compile error: User-defined type not defined

?????

The code is written exactly as written in the article. Can I fix

this?

Thanks for any help

PJ








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Error following Microsoft Article

A change in the code made it work. I had to reference excel in the code.
Thanks for your help.

PJ



"Tom Ogilvy" wrote in message
...
Not necessarily, but if you do have a reference to that library - that is
where workbook is defined and you shouldn't get an error. In excel, the
reference in specific to the activeworkbook in the VBE IDE. I think it is
different in Word, but can't say as I don't do much in the word VBE IDE.

If
the reference is set up properly, you shouldn't get the error. If you do
get the error, then I would say it isn't set up properly.


--
Regards,
Tom Ogilvy

"PJ Usher" wrote in message
...
I'm actually doing this from MS Word but have the Microsoft Excel 9.0

Object
Library referenced.
Am I in the wrong newsgroup?

PJ


"Tom Ogilvy" wrote in message
...
In the VBE in tools = references, do you have a reference to the

Excel
library?

You are doing this in Excel itself; correct?
--
Regards,
Tom Ogilvy

"PJ Usher" wrote in message
...
I followed Microsoft Knowledge Base Article 213299 XL2000: For Each

Loop
to
Determine If an Excel Workbook is Open

When I run the code the line

Dim wb as Workbook

is highlighted and I receive an error

Compile error: User-defined type not defined

?????

The code is written exactly as written in the article. Can I fix

this?

Thanks for any help

PJ










  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Error following Microsoft Article

I went into a new word document and created a reference to Excel.

then put in code

Sub Tester1()
dim bk as Workbook
End Sub

Workbook was offered as an option in intellisense and when I compiled, it
compiled fine. It is good you have it working, but this could be indicative
of other problems that may crop up. I would look in Tools=References and
see if you have any reference marked as MISSING. If so, you need to fix
them or get rid of them.

--
Regards,
Tom Ogilvy

"PJ Usher" wrote in message
...
A change in the code made it work. I had to reference excel in the code.
Thanks for your help.

PJ



"Tom Ogilvy" wrote in message
...
Not necessarily, but if you do have a reference to that library - that

is
where workbook is defined and you shouldn't get an error. In excel,

the
reference in specific to the activeworkbook in the VBE IDE. I think it

is
different in Word, but can't say as I don't do much in the word VBE IDE.

If
the reference is set up properly, you shouldn't get the error. If you

do
get the error, then I would say it isn't set up properly.


--
Regards,
Tom Ogilvy

"PJ Usher" wrote in message
...
I'm actually doing this from MS Word but have the Microsoft Excel 9.0

Object
Library referenced.
Am I in the wrong newsgroup?

PJ


"Tom Ogilvy" wrote in message
...
In the VBE in tools = references, do you have a reference to the

Excel
library?

You are doing this in Excel itself; correct?
--
Regards,
Tom Ogilvy

"PJ Usher" wrote in message
...
I followed Microsoft Knowledge Base Article 213299 XL2000: For

Each
Loop
to
Determine If an Excel Workbook is Open

When I run the code the line

Dim wb as Workbook

is highlighted and I receive an error

Compile error: User-defined type not defined

?????

The code is written exactly as written in the article. Can I fix

this?

Thanks for any help

PJ












  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Error following Microsoft Article

I think that it should be

Dim WB AS Excel.Workbook

But you need to consult Help on how to refer to the Excel application and its
objects from another program like Word.

On Mon, 4 Oct 2004 12:00:55 -0400, "PJ Usher" wrote:

I'm actually doing this from MS Word but have the Microsoft Excel 9.0 Object
Library referenced.
Am I in the wrong newsgroup?

PJ


"Tom Ogilvy" wrote in message
...
In the VBE in tools = references, do you have a reference to the Excel
library?

You are doing this in Excel itself; correct?
--
Regards,
Tom Ogilvy

"PJ Usher" wrote in message
...
I followed Microsoft Knowledge Base Article 213299 XL2000: For Each

Loop
to
Determine If an Excel Workbook is Open

When I run the code the line

Dim wb as Workbook

is highlighted and I receive an error

Compile error: User-defined type not defined

?????

The code is written exactly as written in the article. Can I fix this?

Thanks for any help

PJ








  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Error following Microsoft Article

If there is no duplication, then it shouldn't need to be qualified.

--
Regards,
Tom Ogilvy

"Myrna Larson" wrote in message
...
I think that it should be

Dim WB AS Excel.Workbook

But you need to consult Help on how to refer to the Excel application and

its
objects from another program like Word.

On Mon, 4 Oct 2004 12:00:55 -0400, "PJ Usher" wrote:

I'm actually doing this from MS Word but have the Microsoft Excel 9.0

Object
Library referenced.
Am I in the wrong newsgroup?

PJ


"Tom Ogilvy" wrote in message
...
In the VBE in tools = references, do you have a reference to the Excel
library?

You are doing this in Excel itself; correct?
--
Regards,
Tom Ogilvy

"PJ Usher" wrote in message
...
I followed Microsoft Knowledge Base Article 213299 XL2000: For Each

Loop
to
Determine If an Excel Workbook is Open

When I run the code the line

Dim wb as Workbook

is highlighted and I receive an error

Compile error: User-defined type not defined

?????

The code is written exactly as written in the article. Can I fix

this?

Thanks for any help

PJ








  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Error following Microsoft Article

OK, but why is he getting the error then? Any thoughts?

On Mon, 4 Oct 2004 14:09:42 -0400, "Tom Ogilvy" wrote:

If there is no duplication, then it shouldn't need to be qualified.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
11.04 forex article [email protected] Excel Worksheet Functions 0 November 7th 08 01:58 PM
some forex article [email protected] Excel Worksheet Functions 0 November 7th 08 01:56 PM
Good article on Microsoft Tim Zych Excel Discussion (Misc queries) 0 June 21st 08 06:36 PM
Good article on Microsoft Tim Zych Excel Worksheet Functions 0 June 21st 08 06:36 PM
KB article - 06125: [dbnetlib][connectionopen] error sib Excel Programming 1 August 27th 03 07:52 PM


All times are GMT +1. The time now is 08:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"