XLA problem

Joined
Nov 17, 2006
Messages
1
Reaction score
0
Hi,

I'm currently working on an VBA project which has to enable someone to connect to a database via Excel. Validate his data and delete.
The coding worked fine when placed in a module.
Now I want to have this coding in an Add-in , so when I have some new functions/modifications I don't have to adjust all the excel files.

My problem now is , when I call a function in the XLA which has to perform some sheet modifications , the XLA doesn't seem to find my sheets?

example
(XLA extract)

Function AskID()

Dim WB As Workbook
Set WB = ActiveWorkbook

'HFE_Excel being a sheet on my book1.xls
WB.Sheets("HFE_Excel").Select <-- here I get an error Out of Range

UserForm1.Show ' opens a loginform

End Function

(book1.XLS.ThisWorkbook)

Private Sub workbook_open()
run "AskID"
End Sub


Someone ?
I've been searching on the Net for 2days now, without success
 
Joined
Nov 22, 2006
Messages
2
Reaction score
0
Make sure you have these:

Dim WB As Workbook
Set WB = ActiveWorkbook

right after a macro is called from the sheet. Hence it is before the ActiveWorkbook becomes something else during something like opening another book.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top