Daily Report Template

S

SC in Texas

I have some daily reports templates set up to open and save with a date
related name in a preset folder.
I have them working so that if the file already exists with the date in name
it will add (x). Example C:\MyReports\DailyReport 12-25-09(1).xls for the
second time template is used.
I would like to use a msgbox to give the user a choice of reopening the
first copy rather than making a second.
I have it set up to work except my statements for opening the first file
does not open it.

sample of my code:
If Ans = vbYes Then
Me.Close SaveChanges:=False
Dim wb1 As Workbook
wb1 = Workbooks.Open(myPath & myFile & myExt)
wb1.Activate
wb1.visble = True
Can anyone tell me what I am doing wrong here.
Thanks
SC
 
J

JLGWhiz

You are using the Me key word which in this case probably refers to the
active workbook. If you close the workbook running the code, the rest of
the code will not execute, or it might just give you an error message. Try
opening the other workbook first and then close the workbook running the
code. Better yet, if you do not really want to close the workbook running
the code, then use the actual workbook name or an object variable for it.
 
S

SC in Texas

Thanks "JLGWhiz" I finally realized that I need to change the order of the
commands while driving home yesterday. Should caught that sooner, I guess I
was hung up on needing to close the new report and open the previous made
report and was trying to do it in that order. I already fixed the problem
this morning.
SC
 

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