type mismatch error help

R

ryan.fitzpatrick3

I get a type mismatch error on this. I have one book that is on
windows scheduler, when it opens (on the scheduled time) it auto runs
the macro's in another workbook. It works perfectly except I want it
to close all workbooks without prompting me "do you want to save". How
can I do this without getting a type mismatch error?



Sub Auto_Open()

'The following code provides a general outline to do what you
describe.

Workbooks.Open Filename:= _
"C:\Documents and Settings\rfitz03\Desktop\RYAN'S EXCEL SHEETS
\Strategic Sourcing\Forms\Position Sheet\Flour Position Sheet
2008-1.xls"

Application.Run "'Flour Position Sheet 2008-1.xls'!Access_Data"
Application.Run "'Flour Position Sheet 2008-1.xls'!
Mail_Plant_Info_Range_without_prompt"

Application.DisplayAlerts = False
Workbooks("Automation.xls").Close
Workbooks("Flour Position Sheet 2008-1.xls").Close
Application.DisplayAlerts = True
ThisWorkbook.Saved = True
Application.Quit

End Sub
 
D

dan dungan

I think you need to move this line--"Application.DisplayAlerts = True"
to after "ThisWorkbook.Saved = True"
 
J

Jim Thomlinson

The close method has a couple of optional arguments. The first is to save
changes...

Workbooks("Automation.xls").Close SaveChanges:=False
 
R

ryan.fitzpatrick3

I think you need to move this line--"Application.DisplayAlerts = True"
to after "ThisWorkbook.Saved = True"

This doesn't work, it closes out the automation workbook but not both.
 
R

ryan.fitzpatrick3

The close method has a couple of optional arguments. The first is to save
changes...

Workbooks("Automation.xls").Close SaveChanges:=False

It didn't close both workbooks just automation book. I took your code
and put the other workbook in it underneath.

Application.DisplayAlerts = False
Workbooks("Automation.xls").Close SaveChanges:=True
Workbooks("Flour Position Sheet 2008-1.xls").Close
SaveChanges:=False
Application.DisplayAlerts = True
Application.Quit
 

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