+ Reply to Thread
Results 1 to 3 of 3

Deleting or Disabling code in Excel

  1. #1
    Cathy W
    Guest

    Deleting or Disabling code in Excel

    Hello. I have an excel template that contains code in the background. I
    want to be able to either delete or disable the code when the user saves the
    template as a .xls file. Any ideas? I have tried putting a version of
    "delete code on save" function in the template, but then when I save the
    template - it deletes the template code, which I don't want.

    Thanks,
    Cathy

  2. #2
    Stefi
    Guest

    RE: Deleting or Disabling code in Excel

    Try this event code:

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    If SaveAsUI Then
    Application.EnableEvents = False
    End If
    End Sub

    Regards,
    Stefi


    „Cathy W” ezt *rta:

    > Hello. I have an excel template that contains code in the background. I
    > want to be able to either delete or disable the code when the user saves the
    > template as a .xls file. Any ideas? I have tried putting a version of
    > "delete code on save" function in the template, but then when I save the
    > template - it deletes the template code, which I don't want.
    >
    > Thanks,
    > Cathy


  3. #3
    Cathy W
    Guest

    RE: Deleting or Disabling code in Excel

    Hi Stefi. Thanks for your reply. I already have that event in my code to
    change all forumlas to values before saving so I just added the If statement
    to that event, but it didn't work. I tried putting it before and after but
    didn't work. In my workbook_open event I have a code that calls an open
    diaglog box for the user to select a file so I think this is what has to be
    "disabled" or "deleted" on save.

    Thanks again.

    "Stefi" wrote:

    > Try this event code:
    >
    > Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    > If SaveAsUI Then
    > Application.EnableEvents = False
    > End If
    > End Sub
    >
    > Regards,
    > Stefi
    >
    >
    > „Cathy W” ezt *rta:
    >
    > > Hello. I have an excel template that contains code in the background. I
    > > want to be able to either delete or disable the code when the user saves the
    > > template as a .xls file. Any ideas? I have tried putting a version of
    > > "delete code on save" function in the template, but then when I save the
    > > template - it deletes the template code, which I don't want.
    > >
    > > Thanks,
    > > Cathy


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1