Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Add-in Error , code help

Hi Guys

I have created an AD-in in Excel 2002 (win 2k). It works
fine in Excel format but when I convert it to Add-in I run
into problems.

The following userform event errors out (Run time 91,
obeject variable or with block variable not set)
It happens only when Know other work book is open and Add-
in is open on its own.
Is there a way to ceate a new workbook if know other
workbook is present , select it so that it does not
encounter the error.

Thanks a lot

Private Sub UserForm_Initialize()


Dim WB As Workbook
For Each WB In Workbooks
If WB.Windows(1).Visible = True Then
Me.ListBox1.AddItem WB.Name
End If
Next WB


End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Add-in Error , code help

use this code to trap that error

If ActiveSheet Is Nothing Then Exit Sub


Cesar Zapata




"James" wrote in message
...
Hi Guys

I have created an AD-in in Excel 2002 (win 2k). It works
fine in Excel format but when I convert it to Add-in I run
into problems.

The following userform event errors out (Run time 91,
obeject variable or with block variable not set)
It happens only when Know other work book is open and Add-
in is open on its own.
Is there a way to ceate a new workbook if know other
workbook is present , select it so that it does not
encounter the error.

Thanks a lot

Private Sub UserForm_Initialize()


Dim WB As Workbook
For Each WB In Workbooks
If WB.Windows(1).Visible = True Then
Me.ListBox1.AddItem WB.Name
End If
Next WB


End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Add-in Error , code help

Thanks Cesar
How can I add a new sheet from with Add-in if I want to
Thanks
-----Original Message-----
use this code to trap that error

If ActiveSheet Is Nothing Then Exit Sub


Cesar Zapata




"James" wrote in

message
...
Hi Guys

I have created an AD-in in Excel 2002 (win 2k). It works
fine in Excel format but when I convert it to Add-in I

run
into problems.

The following userform event errors out (Run time 91,
obeject variable or with block variable not set)
It happens only when Know other work book is open and

Add-
in is open on its own.
Is there a way to ceate a new workbook if know other
workbook is present , select it so that it does not
encounter the error.

Thanks a lot

Private Sub UserForm_Initialize()


Dim WB As Workbook
For Each WB In Workbooks
If WB.Windows(1).Visible = True Then
Me.ListBox1.AddItem WB.Name
End If
Next WB


End Sub




.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Add-in Error , code help

I dont understand your question but try this


Sheets("Sheet1").select
Sheets.Add

use the macro recorder to get the code then change it to your needs.



Cesar.



"James" wrote in message
...
Thanks Cesar
How can I add a new sheet from with Add-in if I want to
Thanks
-----Original Message-----
use this code to trap that error

If ActiveSheet Is Nothing Then Exit Sub


Cesar Zapata




"James" wrote in

message
...
Hi Guys

I have created an AD-in in Excel 2002 (win 2k). It works
fine in Excel format but when I convert it to Add-in I

run
into problems.

The following userform event errors out (Run time 91,
obeject variable or with block variable not set)
It happens only when Know other work book is open and

Add-
in is open on its own.
Is there a way to ceate a new workbook if know other
workbook is present , select it so that it does not
encounter the error.

Thanks a lot

Private Sub UserForm_Initialize()


Dim WB As Workbook
For Each WB In Workbooks
If WB.Windows(1).Visible = True Then
Me.ListBox1.AddItem WB.Name
End If
Next WB


End Sub




.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Add-in Error , code help

Hi James,

Your users may not appreciate having new workbooks opened just so that
your add-in doesn't generate an error :)

How about using the Count property of the Workbooks collection to
determine the number of open workbooks and then proceed with the rest
of your routine if it is appropriate to do so.

HTH
Richie

"James" wrote in message ...
Hi Guys

I have created an AD-in in Excel 2002 (win 2k). It works
fine in Excel format but when I convert it to Add-in I run
into problems.

The following userform event errors out (Run time 91,
obeject variable or with block variable not set)
It happens only when Know other work book is open and Add-
in is open on its own.
Is there a way to ceate a new workbook if know other
workbook is present , select it so that it does not
encounter the error.

Thanks a lot

Private Sub UserForm_Initialize()


Dim WB As Workbook
For Each WB In Workbooks
If WB.Windows(1).Visible = True Then
Me.ListBox1.AddItem WB.Name
End If
Next WB


End Sub

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
error in code des-sa[_2_] Excel Discussion (Misc queries) 5 July 3rd 08 08:09 AM
Code error M&M[_2_] Excel Discussion (Misc queries) 4 July 13th 07 12:20 AM
Code error N.F[_2_] Excel Discussion (Misc queries) 1 July 2nd 07 11:13 PM
error in this code [email protected] Excel Worksheet Functions 2 December 5th 06 05:21 AM
Error Code 481 MBlake Excel Discussion (Misc queries) 1 May 11th 05 01:27 PM


All times are GMT +1. The time now is 11:42 AM.

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

About Us

"It's about Microsoft Excel"