Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Save Event - Determine if called by code or user

I found a way to determine if a save event was called by code or by a user.
However, I do not understand exactly why this works or if it will cause any
problems. This code works on Win98 and 2k with Excel 97. Can anyone
explain - please.

The following code is part of an add-in that prompts the user for the
document properties each time a workbook is saved.



Private Sub Appl_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI As
Boolean, Cancel As Boolean)
On Error Resume Next

''' Initialize the ShowInst variable
ShowInst = Workbooks("Document Properties
Prompt.xla").CustomDocumentProperties("ShowInst"). Value

''' Fill in the Document Properties that are blank with Instructions
If ActiveWorkbook.BuiltinDocumentProperties("Title"). Value = "" Then
ActiveWorkbook.BuiltinDocumentProperties("Title"). Value = "Enter the
File Name"
End If
If ActiveWorkbook.BuiltinDocumentProperties("Subject" ).Value = "" Then
ActiveWorkbook.BuiltinDocumentProperties("Subject" ).Value = "Enter a
brief Description of the File"
End If
If ActiveWorkbook.BuiltinDocumentProperties("Author") .Value = "" Then
ActiveWorkbook.BuiltinDocumentProperties("Author") .Value = "Enter
the 8 digit User ID of the person responsible for the File"
End If
If ActiveWorkbook.BuiltinDocumentProperties("Comments ").Value = "" Then
ActiveWorkbook.BuiltinDocumentProperties("Comments ").Value = "Enter
a Date in ""YY/MM/DD"" format followed by a brief description of changes
made followed by a simicolon (;) then press enter"
End If

''' Check to see if the InstForm should be shown
'''=============================================== ==========================
====
''' I am not sure why this works or what the xlDialogEditionOptions
''' dialog is supposed to do. However, it will return TRUE or FALSE
''' based on whether it should show or not. Like the xlDialogProperties
''' dialog, it will not show when the save was called from code returning
''' FALSE. It will not show when the save was called by a user either, but
''' it will return TRUE just like the xlDialogProperties does when it shows.
''' So xlDialogEditionOptions will work as a test for wether or not the
''' save event was called from code or by a user.
'''=============================================== ==========================
=====
If Application.Dialogs(xlDialogEditionOptions).Show Then
If ShowInst = True Then
InstForm.Show
End If
End If

''' Show the Properties dialog
Application.Dialogs(xlDialogProperties).Show

End Sub


Can anyone tell me what the xlDialogEditionOptions dialog is for or what it
does or if this will cause any problems?
I need to distribute this add-in company wide and I want to make sure it
won't cause problems. I have tested it on about a dozen machines so far with
out any problems.

David Sedberry




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
What code do I use to attach event handler that will open my user. TeresaManley Excel Worksheet Functions 2 May 5th 07 09:55 PM
In the worksheet_change event, how do I determine what occured? Tim Patton Excel Worksheet Functions 6 November 3rd 05 08:38 PM
user event driven macro issue Jean-Paul Viel Excel Programming 0 September 18th 03 05:32 PM
user event driven macro issue steve Excel Programming 0 September 18th 03 05:00 PM
prevent user from saving file to a folder but allow my code to save from behind. susie Excel Programming 3 July 25th 03 03:01 PM


All times are GMT +1. The time now is 03:43 PM.

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"