Consulting

Results 1 to 4 of 4

Thread: Solved: Copy sheet without the vba code

  1. #1
    VBAX Regular
    Joined
    Jan 2010
    Posts
    11
    Location

    Solved: Copy sheet without the vba code

    Hello there,

    I have visited this site: rondebruin.nl and have found very useful information on sending emails via vba in excel.

    Everything works great, but I need someting that I could not find there.

    I need to copy the whole worksheet, becuase I need to send it with its original layout, but not to include the vba code that is attached to this sheet.

    Mailing Range or selections does not work for me. I need the whole sheet as it is but wihtout the vba code that goes with the sheet.

    Any ideas?

    Many thanks to all!

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [vba]
    Sub DoCopy()
    ActiveSheet.Copy
    DeleteAllVBA
    End Sub

    Private Sub DeleteAllVBA()
    'http://www.vbaexpress.com/kb/getarticle.php?kb_id=64
    'by Smozgur

    Dim vbComp As Object

    For Each vbComp In ActiveWorkbook.VBProject.VBComponents

    With vbComp
    If .Type = 100 Then
    .CodeModule.DeleteLines 1, .CodeModule.CountOfLines
    Else
    ActiveDocument.VBProject.VBComponents.Remove vbComp
    End If
    End With
    Next vbComp

    End Sub
    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Jan 2010
    Posts
    11
    Location
    Many thanks!

    It does the job!

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Glad to help. You can mark the thread solved using the thread tools dropdown.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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