View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Error in Workbook_Open

Error 91 is when an Object variable is not Set. If your code had been posted
someone could probably spot the problem.

"matt" wrote:

Hello,

I have an excel file that I get as an attachment everymonring with a table
in it. Every monring I save the attachment over the previous day's file.
If I open the document and then open the VB editor in the project explorer
on the left, there is two projects the first I believe Personal.xls and the
second is the attachment file that I was talking about.
I wanted to create a macro that runs on the open of the file using "Private
Sub Workbook_Open" but the problem is everytime I save the attachment, the
code for that file gets wiped out.
So I was trying to write a "Workbook_Open" under the
"Personal.xls"/"ThisWorbook". But the problem is when I open the file,
"personal.xls" project opens first then my files project opens. Now I think
It is trying to run this code before it open my files workbook, and dosen't
find it. I get an "Error 91" I click cancel, and then my file opens.
The code that I wrote works if I step through it in the VB Editor, but I get
the error on the open of the file.
Any thoughts?