Results 1 to 3 of 3

Thread: RESOLVED[Deleting Vba code - Urgent]

  1. #1

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Exclamation RESOLVED[Deleting Vba code - Urgent]

    I have a user form which gives you in the end a report of the data you filled. This report is printed in a worksheet called Report. In this worksheet the is at the bottom a text box grouped with some image in a shape as backgroud. In this text box you enter the name of the report, and then, after a click on Save button you get the following code:

    VB Code:
    1. Private Sub cmdSave_Click()
    2.  
    3. Dim Dest As Workbook
    4.  
    5.     file= ThisWorkbook.Path & "\" & txtFile.Value & ".xls"
    6.     Worksheets("Report").Copy
    7.     Set Dest = ActiveWorkbook
    8.     Dest.SaveAs file
    9. ' Here the Shape and the text box which where grouped are deleted, so that
    10. ' you only see the report
    11.     ActiveSheet.Shapes("Group 1").Select
    12.     Selection.Delete
    13.     ActiveSheet.Range("A1").Select
    14.     ActiveWorkbook.Save
    15.    
    16. End Sub

    It works just fine. However, my question is, is it possible that once it is saved in the new location, the Vba code gets deleted, in order to have only an Excel sheet which will not ask you every time about the macro security?
    Last edited by Fonty; Jun 19th, 2006 at 11:38 AM.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Deleting Vba code - Urgent

    Can't you create a new workbook and sheet, and put the report in there?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Deleting Vba code - Urgent

    If you have VBA code behind the sheet object then that will get copied over too. You will need to copy the range on your sheet and paste it into the new blank sheet.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width