Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/05/2015, 12:20
JoaoM
 
Fecha de Ingreso: agosto-2007
Mensajes: 1.945
Antigüedad: 16 años, 8 meses
Puntos: 39
Necesidad de agregar nuevos requisitos a la macro

Hola gente buena

En resumen lo que quiero es:

Que copie la hoja (rango) (crie) en PDF (ya lo hace)
Que copie la hoja (rango) (crie) en xlsx (ya lo hace)
Que elimine TODA macro DE LA COPIA .xlsx (ya lo hace)
Que no transporte las formulas del origen a la copia (ya lo hace)
Que elimine todos los botones DE LA COPIA .xlsx solamente (ya lo hace).
Que proteja (TODO) su contenido, formas, datos, ETC en la copia .xlsx solamente, con passw o de alguna forma pero que la proteja de forma a que NADIE pueda modificar dato alguno en la copia. Ahora solo protege las formas que existen, quiero proteger TODO

Al abrir la copia, se ve TODO el rango seleccionado, QUE NO SEA ASÍ

En el libro origen, SI PROTEJO LA HOJA dejando solo LAS CELDAS A USAR desbloqueadas, me manda errores y quiero que protegida me deje ejecutar la macro, aunque tenga la J2, J3 y L3 desbloqueadas y desprotegidas, como se reflejan en la macro.

Esta la macro
Código:
Sub GuardaSinMacros()

    Dim ruta    As String
    Dim nombre  As String
    Dim wb      As Object
    Dim i       As Long
    Dim d       As String
    ruta = "C:\0\1\"
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    With ThisWorkbook.Sheets(1)
        nombre = .Range("G4") & "_" & .Range("C13") & " " & .Range("D13") & "-" & .Range("H13").Value
        .Copy
    End With
    Set wb = Workbooks(Workbooks.Count)
    With wb
        With .Sheets(1)
            For i = .Shapes.Count To 1 Step -1
                d = .Shapes(i).TopLeftCell.Address(False, False)
                Select Case d
                    Case "J2": .Shapes(i).Delete
                    Case "J3": .Shapes(i).Delete
                    Case "L3": .Shapes(i).Delete
                End Select
            Next
            With .Range("B2:J60")
                .ExportAsFixedFormat Type:=xlTypePDF, Filename:=ruta & nombre & ".pdf", _
                                     Quality:=xlQualityStandard, IncludeDocProperties:=True, _
                                     IgnorePrintAreas:=False, OpenAfterPublish:=False
                .Copy
                .PasteSpecial xlPasteValues
                Application.CutCopyMode = False
            End With
            With .Cells
                .Locked = True
                .FormulaHidden = False
            End With
            .Protect Password:=1234, DrawingObjects:=True, Contents:=True, Scenarios:=True
            .EnableSelection = xlNoRestrictions
        End With
        .SaveAs Filename:=ruta & nombre & ".xlsx", FileFormat:=xlOpenXMLWorkbook, _
                CreateBackup:=False
        .Close True
    End With
    Set wb = Nothing
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    With ThisWorkbook
        With .Sheets(1).Range("I3")
            .Value = .Value + 1
        End With
    End With
End Sub
Este el enlace al libro, porque creo que es mejor trabajar sobre el libro que estar construyendo uno para prueba
http://turbobit.net/yn8tcdinb3lw.html
__________________
Las contraseñas son como la ropa interior: Nunca dejarlas donde la gente pueda verlas
http://i64.tinypic.com/rho40i.jpg