LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to prevent saving over Excel and Word Files

Hello,

I'm new to VBA, but it seems quite powerful sometimes. We have a
system, where the user browses to a folder on the server, and opens his
choice of excel file. In this excel file, there is a form, with some
VBA in the background, where one can fill out the form and press a
control button in the excel file, which will place the gathered
information in the excel into a word template with the same name. This
word template exists in the same folder as the excel files.


The assumption of the system is that people will open the excel file,
fill out the form, link the information to word, then save the FINAL
word file locally or simply print it, and then close both the excel
file and the word file without saving.

However, every once in a while, a user messes up and saves either the
filled out excel file or the filled out word file over the template!
and a restoration of the backup has to be performed.

Now, I am new to VBA, but it seems to me like this should be very
easily preventable, by simply opening the excel file and the word file
without the SAVE AS path pointing to their original locations, I mean
I've seen that behaviour before, where you try to save the file, and
it'll prompt you for a new path that probably starts on your desktop or
something like that. Basically, not giving you the option to press SAVE
and overwrite the original templates.

Notice that the files on the server are readOnly, but the saving over
still happens.

the code below is how the Word file is instantiated from within the VBA
code:

'Contains the name and path of the associated contract template
Const csFilename As String = "---absoluteServerPathtoFile---"

'Retrieve a word application instance if possible, else create one
On Error Resume Next
Set wd = GetObject(, "word.application")

If Err.Number < 0 Then
Err.Clear ' Clear Err object in case error occured.
Set wd = CreateObject("word.application")
End If


'Open the template file
wd.documents.Open csFilename




Any input is appreciated, I'm sure lots of you out there have enough
experience to tackle this one, and I'm really appreciative if you can
share you knowledge with the rest of us,
Thanx alot in advance,

Sincerely,
Mjd

 
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
Navigating to Excel files over network slow, but not Word files Newbie123 Excel Discussion (Misc queries) 1 December 2nd 09 01:18 PM
HOW CAN I PREVENT EXCEL FILES FROM BEING DELETED OR PREVENT TRASH ROB Excel Discussion (Misc queries) 2 April 2nd 07 01:13 PM
How do I prevent saving an excel file if cells are blank? Leighann Excel Worksheet Functions 1 November 4th 06 07:40 PM
convert 400 word files to excel files fast? CPower[_13_] Excel Programming 1 June 21st 04 10:29 AM
prevent user from saving excel file to a folder susie Excel Programming 2 July 24th 03 09:12 PM


All times are GMT +1. The time now is 08:42 AM.

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

About Us

"It's about Microsoft Excel"