Save Excel WorkBook - a special way

  • Thread starter Thread starter Anirban
  • Start date Start date
A

Anirban

I need to write VBA code embedded to a workbook in such a
way that, if the workbook is in a particular directory (sa
C:\WinNT\Temp) , the save option work as "SaveAs"

(Or in otherway to behave the WorkBook as if
it is never saved... ThisWorkBook.Path = "")

I tried to write in the thisWorkBook Module ...

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel A
Boolean)
Dim bCodeRunning As Boolean
bCodeRunning = False
If ThisWorkBook.Path = strTempDir Then
If bCodeRunning Then
Application.Dialog(xlSaveAs).Show
bCodeRunning = False
Else
bCodeRunning = True
End If
End If
End Sub


What else I need to do to get the desired effect?
Please help
 
Hi
you should also add the line
Cancel=True
at the end of this macro

and in addition the line
application.enableevents = False
at the gebinning and
application.enableevents=True
at the end of your macro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top