Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Need Help Writing VB Code on a Template

When I open a template file and complete my entries, I would like to discard
all inputs made to that file and start over.

Question: Is there a way I can write a clode labeled "Reset" where Excel
will close and discard any changes to that file and reopens a new template
file?

For example... below I have a code written for MS Word and it works by
discarding the current file and reopens a new one. I just don't know how to
do it in MS Excel.

Dim LastDocument As Document
Set LastDocument = Active Document
OpenNewBlankDocument
LastDocument.Close SaveChanges:=wdDoNotSavechanges

Thank you,

Tom
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Need Help Writing VB Code on a Template

ThisWorkbook.Close SaveChanges:=False

"TomP" wrote:

When I open a template file and complete my entries, I would like to discard
all inputs made to that file and start over.

Question: Is there a way I can write a clode labeled "Reset" where Excel
will close and discard any changes to that file and reopens a new template
file?

For example... below I have a code written for MS Word and it works by
discarding the current file and reopens a new one. I just don't know how to
do it in MS Excel.

Dim LastDocument As Document
Set LastDocument = Active Document
OpenNewBlankDocument
LastDocument.Close SaveChanges:=wdDoNotSavechanges

Thank you,

Tom

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Need Help Writing VB Code on a Template

What would I put on the next line to reopen the same template?

Thank you,

"JLGWhiz" wrote:

ThisWorkbook.Close SaveChanges:=False

"TomP" wrote:

When I open a template file and complete my entries, I would like to discard
all inputs made to that file and start over.

Question: Is there a way I can write a clode labeled "Reset" where Excel
will close and discard any changes to that file and reopens a new template
file?

For example... below I have a code written for MS Word and it works by
discarding the current file and reopens a new one. I just don't know how to
do it in MS Excel.

Dim LastDocument As Document
Set LastDocument = Active Document
OpenNewBlankDocument
LastDocument.Close SaveChanges:=wdDoNotSavechanges

Thank you,

Tom

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Need Help Writing VB Code on a Template

Why do you want to discard changes?

If the file is a true Tempate(*.xlt) a new workbook is opened based upon
that Template.

The Template itself does not open so is not changed in any manner.


Gord Dibben MS Excel MVP


On Wed, 5 Nov 2008 08:31:01 -0800, TomP
wrote:

When I open a template file and complete my entries, I would like to discard
all inputs made to that file and start over.

Question: Is there a way I can write a clode labeled "Reset" where Excel
will close and discard any changes to that file and reopens a new template
file?

For example... below I have a code written for MS Word and it works by
discarding the current file and reopens a new one. I just don't know how to
do it in MS Excel.

Dim LastDocument As Document
Set LastDocument = Active Document
OpenNewBlankDocument
LastDocument.Close SaveChanges:=wdDoNotSavechanges

Thank you,

Tom


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Need Help Writing VB Code on a Template

You would use the Workbooks.Open method. Most of this is spelled out in the
VBA help files which can be accessed in the VB editor mode. But as Gord
points our, if you are using a template with the .xlt suffix, then it
automatically creates a new workbook when you open it and the original
template reamains unchanged. So if you do not want to keep the changes you
make, just close it without saving and it will go away. You can then open
the original template and start all over.

"TomP" wrote:

What would I put on the next line to reopen the same template?

Thank you,

"JLGWhiz" wrote:

ThisWorkbook.Close SaveChanges:=False

"TomP" wrote:

When I open a template file and complete my entries, I would like to discard
all inputs made to that file and start over.

Question: Is there a way I can write a clode labeled "Reset" where Excel
will close and discard any changes to that file and reopens a new template
file?

For example... below I have a code written for MS Word and it works by
discarding the current file and reopens a new one. I just don't know how to
do it in MS Excel.

Dim LastDocument As Document
Set LastDocument = Active Document
OpenNewBlankDocument
LastDocument.Close SaveChanges:=wdDoNotSavechanges

Thank you,

Tom

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IS IT POSSIBLE IN EXCEL WITHOUT WRITING CODE. HARSHAWARDHAN. S .SHASTRI[_2_] Excel Worksheet Functions 14 February 4th 09 04:48 PM
Need help writing Code LeAnne Excel Discussion (Misc queries) 1 February 15th 08 03:27 PM
Writing and erasing code with code bobbo Excel Programming 4 October 11th 06 08:28 PM
Writing and reading from a template Excel file using ADO.Net - results not recalculated RJN Excel Programming 0 April 26th 06 05:39 PM
Need some help writing code. Erik[_6_] Excel Programming 5 February 29th 04 06:51 PM


All times are GMT +1. The time now is 06:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"