Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default problem to access sheet from add-in

Hello,

I've createad an add-in (with a function called ratings) in which I get some
value from a sheet that have to be created in order to use my add-in. It
worked perfectly for a few days but now whenever I open my excel sheet and
the use the function from my add-in I get an error because excel cannot find
the sheet I use to make some calculation in my excel file. I think that my
add-in is tryin to the sheet within my add-in ...

Please someone help me ! Thanks in advance.

I use the following code to make sure I can acces a specific sheet in my
add-in:

Dim wSheet As Worksheet

On Error Resume Next

Set wSheet = Sheets("ratings_sheet")

if wSheet is Nothing then
msgbox "i've got a serious problem"
else
msgbox "everything is cool"
end if



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default problem to access sheet from add-in

Try prefixing the Sheets collection object with ActiveWorkbook.

Set wSheet = ActiveWorkbook.Sheets("ratings_sheet")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Nader" wrote in message
...
Hello,

I've createad an add-in (with a function called ratings) in
which I get some value from a sheet that have to be created in
order to use my add-in. It worked perfectly for a few days but
now whenever I open my excel sheet and the use the function
from my add-in I get an error because excel cannot find the
sheet I use to make some calculation in my excel file. I think
that my add-in is tryin to the sheet within my add-in ...

Please someone help me ! Thanks in advance.

I use the following code to make sure I can acces a specific
sheet in my add-in:

Dim wSheet As Worksheet

On Error Resume Next

Set wSheet = Sheets("ratings_sheet")

if wSheet is Nothing then
msgbox "i've got a serious problem"
else
msgbox "everything is cool"
end if





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default problem to access sheet from add-in


Chip's solution may be problematic if your workbook is an addin.

Since an addin is defacto hidden it is very unlikely it will ever be
the activeworkbook. (unless you toggle the IsAddin property.)

Following WILL work:
Set wSheet= Thisworkbook.Sheets("Ratings_sheet")

BUT it may be more practical to use the 'CODEname' of your worksheet.
if that belongs to the same VBAproject iso using worksheet variables

e.g. if the codename of your worksheet = wksRatings

then debug.print wksRating.Range("A1") will work perfectly.




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Nader wrote in

Hello,

I've createad an add-in (with a function called ratings) in which I
get some value from a sheet that have to be created in order to use
my add-in. It worked perfectly for a few days but now whenever I open
my excel sheet and the use the function from my add-in I get an error
because excel cannot find the sheet I use to make some calculation in
my excel file. I think that my add-in is tryin to the sheet within my
add-in ...

Please someone help me ! Thanks in advance.

I use the following code to make sure I can acces a specific sheet in
my add-in:

Dim wSheet As Worksheet

On Error Resume Next

Set wSheet = Sheets("ratings_sheet")

if wSheet is Nothing then
msgbox "i've got a serious problem"
else
msgbox "everything is cool"
end if

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default problem to access sheet from add-in

use thisworkbook.
if you want to refer to addin worksheets.



Nader wrote:
Hello,

I've createad an add-in (with a function called ratings) in which I get some
value from a sheet that have to be created in order to use my add-in. It
worked perfectly for a few days but now whenever I open my excel sheet and
the use the function from my add-in I get an error because excel cannot find
the sheet I use to make some calculation in my excel file. I think that my
add-in is tryin to the sheet within my add-in ...

Please someone help me ! Thanks in advance.

I use the following code to make sure I can acces a specific sheet in my
add-in:

Dim wSheet As Worksheet

On Error Resume Next

Set wSheet = Sheets("ratings_sheet")

if wSheet is Nothing then
msgbox "i've got a serious problem"
else
msgbox "everything is cool"
end if



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
Access to Excel problem raviyah Excel Discussion (Misc queries) 4 October 8th 08 03:18 PM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
Excel 97 problem with access rwet Excel Discussion (Misc queries) 1 May 22nd 05 05:53 PM
Problem doing Query to Access with Excel sheet protected Harry[_8_] Excel Programming 3 February 26th 05 03:46 PM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM


All times are GMT +1. The time now is 01:32 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"