Jumat, 01 September 2017

Sv: [ExcelVBA] BeforeSave - event - working on all files

 

Hi Lisa!

Thanks for your answer.

I will try to do some research and see what I come up with.

If I succeed I'll tell you all!

Perhaps someone else has any suggestions.

regards Torstein

Den Torsdag, 31. august 2017 21.14 skrev "Green 1z@compuserve.com [ExcelVBA]" <ExcelVBA@yahoogroups.com>:


 
Hi Torstein!

I'm not sure if this will help but this is what I use to shut down Excel.
Maybe it can be "adjusted" to suit what you want.

I've also tried many times to implement/build a "general" error routine but that has escaped me because as you say... one problem is where to put it!

I can only think that you may have to put code into the before save event that calls code in another open workbook or an add in.

An Add In may be a good choice actually because it gets loaded when you open excel and can be made available to all projects.

HTH
Lisa


Sub subShutDownExcel()
' Save all workbooks and quit.

Dim wblWorkBook As Workbook
Dim slWorkBooks() As String
Dim lngErrNumber As Long
Dim blnlDone As Boolean
Dim lnglWorkBooksOpen As Long
Dim lnglClosed As Long

lnglWorkBooksOpen = Workbooks.Count
lnglClosed = 0

blnlDone = False
With Application
  Do
    For Each wblWorkBook In Workbooks
      On Error Resume Next
      Application.DisplayAlerts = False
      wblWorkBook.Save
      Application.DisplayAlerts = True
      wblWorkBook.Close
      lngErrNumber = Err.Number
      On Error GoTo 0
      Select Case lngErrNumber
      Case 0
        lnglClosed = lnglClosed + 1
      End Select
    Next wblWorkBook
    If lnglClosed = lnglWorkBooksOpen Then
      Exit Do
    ElseIf lnglClosed > 10 Then
      ' Sanity check.
      Exit Do
    End If
  Loop
  .Quit
End With

' ***********************************************************************
End Sub



-----Original Message-----
From: Torstein Johnsen sejohnse@yahoo.no [ExcelVBA] <ExcelVBA@yahoogroups.com>
To: Yahoogroups <excelvba@yahoogroups.com>
Sent: Thu, Aug 31, 2017 9:19 am
Subject: [ExcelVBA] BeforeSave - event - working on all files



I know the beforeSave-event that can be added to a workbook and executes before the user saves that workbook.

I want to make a general beforeSave-event that executes before the user saves any workbook.

I suppose I may have missed something about Application events but I can't figure out where to put such an event.

My goal is to make a log of each file saved.

r egards Torstein




__._,_.___

Posted by: Torstein Johnsen <sejohnse@yahoo.no>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.

----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------

.

__,_._,___

Tidak ada komentar:

Posting Komentar