Don't prompt to save template

BenMiller

Well-known Member
Joined
Nov 17, 2011
Messages
1,964
Office Version
  1. 365
Platform
  1. Windows
I have a macro which opens a template and creates a bunch of worksheets from it, then closes the template file. When it's finished running, it prompts and asks if I want to save Template (2). How do I stop it from prompting this? I will never want to resave the template under a new name; I want to keep it as is.

I can post the code if needed.

Thanks!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
What does your file close statement for the template in VBA look like?
I think some close commands have an argument for saving the file, and setting it as "False" will stop that prompt.
Otherwise, you may be able to surround the close command with code like this:
Code:
Application.DisplayAlerts = False
[I]'  Close file statement
[/I]Application.DisplayAlerts = True
 
Upvote 0
Sorry, just got back to this project. Thanks! Worked like a charm :)

As part of this macro, I'm opening a template which contains many links ...Excel prompts me Update Links or not to. How do I remove this prompt? I tried putting
Code:
[LEFT][COLOR=#333333]Application.DisplayAlerts = False
before everything! Doesn't work :( Any ideas? Thanks![/COLOR][/LEFT]
 
Upvote 0
See the UpdateLinks argument to Workbooks.Open.
 
Upvote 0
Ok, I'll definitely check that out ... thanks!
 
Upvote 0
I can't seem to figure it out ... I'm doing it as follows. Am I writing it incorrectly?

Code:
NewFn = Application.GetOpenFilename(FileFilter:="Microsoft Excel file (*.xlsm), *.xlsm", Title:="Please select last month's file")
If NewFn = False Then
' They pressed Cancel
MsgBox "You will have to copy numbers manually."
Exit Sub
Else
    [B]Workbooks.Open "Filename:=NewFn", "UpdateLinks:=2"[/B]
 
Upvote 0
Thanks! And leave out the parentheses too? Sorry, this is my first time trying to do something with VBA :)
 
Upvote 0
If you just use Workbooks.Open then no parenthesis required
Workbooks.Open Filename:=NewFn, UpdateLinks:=2

If you set the opened workbook to a variable when you open it, then parenthesis are required.
Set wb = Workbooks.Open(Filename:=NewFn, UpdateLinks:=2)
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,218
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top