+ Reply to Thread
Results 1 to 2 of 2

Save XLSM without running, but retaining macros

Hybrid View

  1. #1
    Registered User
    Join Date
    11-18-2011
    Location
    Pittsburgh, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Question Save XLSM without running, but retaining macros

    Okay, I am building an Excel 2010 spreadsheet for use as a SharePoint library template. The following VBA code is in the ThisWorkbook object.

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    If Worksheets("Sheet1").Range("H2").Value = "[Select]" Then
    MsgBox "You must make a selection for On-Call Week Length (H2)."
    Cancel = True
    End If
    If Worksheets("Sheet1").Range("AA2").Value = "[Type Name Here]" Then
    MsgBox "You must type your name in the Employee field (AA2)."
    Cancel = True
    End If
    End Sub
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    ActiveSheet.Range("A2").Value = ActiveSheet.Range("A2").Value
    Dim SharePointPath As String
    SharePointPath = "<PATH>"
        Application.EnableEvents = False
        ThisWorkbook.SaveAs Filename:=SharePointPath & "/" & Format([A2], "mm-dd-yyyy") & ".xlsm", FileFormat:=52
        Cancel = True
        Application.EnableEvents = True
    End Sub
    Can I save the workbook without the scripts running, but so they will run the next time the workbook is opened via the SharePoint library?

  2. #2
    Registered User
    Join Date
    11-18-2011
    Location
    Pittsburgh, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Save XLSM without running, but retaining macros

    BTW, removed the path in the SharePointPath variable, but the code works as intended. I just mainly need to save it without the "ActiveSheet.Range("A2").Value = ActiveSheet.Range("A2").Value" line running and removing the formula in the A2 field, but that does need to run whenever a final workbook is saved to the library from the template. Anyone at all able to help with this? Internet searches have yielded nothing helpful.
    Last edited by adkaraczun; 09-20-2012 at 07:07 AM.

+ 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