+ Reply to Thread
Results 1 to 2 of 2

Deleting all VBA code using VBA???

  1. #1
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Deleting all VBA code using VBA???

    Does anyone know how, using VBA to get a workbook to delete all the code before saving?

    Im trying to make a backup copy of a workbook which is date stamped (this i can manage fine!) but the back up that i make needs to have all the code removed from it when its created so that it never makes another copy of itself or performs the task of the original.

    Any ideas??

    Simon.

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    This is what i have so far, it makes the copy fine, but the copy when opened makes another copy and so on......when the copy is made i dont want the copy to have any code in it....is this possible?

    Simon

    Sub auto_open()
    Dim lStr_TargetFile As String
    Dim sStr As String


    If ThisWorkbook.Name <> ThisWorkbook.Name & " - " & Format("ddmmyyyy") & ".xls" Then
    ElseIf ThisWorkbook.Name = ThisWorkbook & " - " & Format("ddmmyyyy") & ".xls" Then
    Call DeleteModule
    ThisWorkbook.Save
    End If
    If ActiveSheet.Rows.Count >= 5 Then
    With ThisWorkbook
    sStr = .Path & "\" & _
    Left(.Name, InStr(1, _
    LCase(.Name), _
    ".xls") - 1) & _
    " - " & Format(Now, "ddmmyyyy") & ".xls"
    MsgBox "hi"

    .SaveCopyAs sStr

    SetAttr sStr, vbArchive

    .Save

    End With
    End If

    End Sub

+ 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