View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default BeforeSave Problem

hi,
rob answered your question. i was suspecting something along the cancel
event but was not sure.
but to answer your question.
open the vb editor. display the macro int the vb window.
click the left margin. a redish brown dot will appear. then click the start
macro icon. looks lilke a arrow head pointing right. the macro will run to
the dot and stop. by pressing F8, the macro will execute the code 1 line at a
time. this is a good de-bug tool.

regards
FSt1

"Andibevan" wrote:

How do you step through an event driven macro?

"FSt1" wrote in message
...
hi,
have you tried to step throught the code to see what line is crashing the
macro?

FSt1

"Andibevan" wrote:

Hi All,

I am trying to create a beforeSave event so that when the user presses

save,
an inputbox comes up and the user specifies part of the filename and

then
the code automatically adds additional information to the filename. I

have
two problems:-

1) My code causes excel to crash
2) The inputbox comes up twice for some reason

Any ideas:-

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

Dim FilePath As String
Dim varInput As String

FilePath = "S:\SmartMarket\SMV Project

Administration\Sign-Offs\Construct
Phase\"

On Error GoTo addError
varInput = InputBox("......\Sign-Offs\Construct Phase\SMV - Sign-Off

for
XXXXX.xls", _
"Sign-off Sheet Description")

ActiveWorkbook.SaveAs Filename:=FilePath & varInput & ".xls"

addError:

MsgBox "No value submitted - File Not Saved"

End Sub

Ta

Andi