Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Save excel file before printing

In my project i have a before_save event with many contions and then if
all conditions are met i make a folder and name the file with info from
cell A1 ( if the file exist then it overwrites it).
Then i have a before_print event and i woulld like to save the file
before printing it. My problem is that how do i get it to go to before
save event to check the conditions then save. Currently if i want to
print it, it saves the file without the conditions met.
------------------------------------
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)(works fine)
if condition 1 then cancel = true
if condition 2 then cancel = true
else make directory
save file with value in cell A1
End Sub
-----------------------------------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
if condition 1 then cancel = true (same cindition in before_save)
if condition 3 cancel = true
else
activeworkbook.save (it saves without going to before_save)
End Sub
----------------------------------
I am using excel 2003
Any help will be appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Save excel file before printing

Nasim,
Create a new function, maybe called ValidationCheck, and return a true/false
(or maybe an problem description string) result. Depending on the outcome,
allow/deny the print and/or save.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If ValidationCheck("BeforeSave") = False Then
MsgBox "Cannot Save"
Cancel = True
Exit Sub
End If
End Sub

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ValidationCheck("BeforePrint") = False Then
MsgBox "Cannot Print"
Cancel = True
Exit Sub
End If
End Sub

Function ValidationCheck(CallingRoutine As String) As Boolean

Select Case LCase(CallingRoutine)
Case "beforesave"
'Save specific Validation code
Case "beforeprint"
'Print specific Validation code
End Select
'Validation code for both/all

ValidationCheck = True ' Or False

End Function

NickHK

"Nasim" wrote in message
oups.com...
In my project i have a before_save event with many contions and then if
all conditions are met i make a folder and name the file with info from
cell A1 ( if the file exist then it overwrites it).
Then i have a before_print event and i woulld like to save the file
before printing it. My problem is that how do i get it to go to before
save event to check the conditions then save. Currently if i want to
print it, it saves the file without the conditions met.
------------------------------------
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)(works fine)
if condition 1 then cancel = true
if condition 2 then cancel = true
else make directory
save file with value in cell A1
End Sub
-----------------------------------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
if condition 1 then cancel = true (same cindition in before_save)
if condition 3 cancel = true
else
activeworkbook.save (it saves without going to before_save)
End Sub
----------------------------------
I am using excel 2003
Any help will be appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Save excel file before printing


Nick,

Thanks for replying but i don't understand how it workes. i don't see
it saving the file to my desired location befor printing it(if all
conditions are met). if you need my codes i can send them to you or
copy here.
Nasim

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Save excel file before printing

Nasim,
Well no, the code does not do much. You will need to add you checks and
..saveas if that is what you need.
It was just to outline what you need to do to have the same validation from
the _BeforePrint and _BeforeSave.
If the validation fails, the function returns False and the Save or Print is
cancelled (Cancel=True).
Otherwise those events complete.

NickHK

"Nasim" wrote in message
ups.com...

Nick,

Thanks for replying but i don't understand how it workes. i don't see
it saving the file to my desired location befor printing it(if all
conditions are met). if you need my codes i can send them to you or
copy here.
Nasim



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Save excel file before printing

Thanks for your time and effort Nick. I think i have a lot to learn.

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
Save excel file before printing Nasim Excel Worksheet Functions 0 December 7th 06 07:18 AM
'document not saved' for 'save' or 'save as' an EXCEL file Judy Chuang Excel Discussion (Misc queries) 1 July 11th 05 10:12 PM
Save Excel file - prompts to save - no Volitile functions used POWER CERTS Excel Worksheet Functions 2 November 1st 04 09:27 PM
Excel marcos firing on file save as but not file save Andy Excel Programming 1 August 3rd 04 10:34 AM
Getting "Save as PDF File" Dialog at end of printing to PDF using PDFwriter Chuck Reed Excel Programming 4 May 13th 04 12:01 PM


All times are GMT +1. The time now is 08:12 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"