Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
monaahmed2012
Femeie
25 ani
Calarasi
cauta Barbat
25 - 46 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [EXCEL] Remove VBA Code From a Workbook using VBA [VBA] Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 748
You can have the following code in a module in personal.xlsb and when you press the button it will remove any code that you have in the active workbook. This is useful in case you want to use row auto-highlighting when cell is selected, but don't want to save a macro enabled file, but with a normal xls/xlsx file. Then first you run the code below using your QAT button so your worksheet is clean of VBA, then save like you normally do.


Sub Z_3RemoveVBAinActiveSheetCode()

Dim activeIDE As Object 'VBProject
Set activeIDE = ActiveWorkbook.VBProject

Dim Element As VBComponent

Dim LineCount As Integer
For Each Element In activeIDE.VBComponents
    If Left(Element.Name, 5) = "Sheet" Then    'change name if necessary
        LineCount = Element.CodeModule.CountOfLines
        Element.CodeModule.DeleteLines 1, LineCount
    End If
Next

End Sub


Works with:

Modificat de TRaP (acum 5 ani)


pus acum 5 ani
   
Pagini: 1  

Mergi la