Error al ejecutar Macro 2 veces
Cuando ejecuto esta macro 2 veces sin cerrar el libro así sea que lo guarde antes de ejecutarlo en la segunda vez se me bloquea excel.
Sub Generacion_Plano()
'
' Macro1 Macro
'
'Con esta macro es para generar el archivo plano
'
ActiveWorkbook.Save
Range("tabla1").Copy
Sheets.Add After:=ActiveSheet
ActiveSheet.Name = "Plano"
Range("a2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Rows("1:1").Select
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
Cells.Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.Font.Bold = True
Selection.Font.Bold = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("C2").Select
Application.CutCopyMode = False
Range("A1").Select
ActiveCell.FormulaR1C1 = "S"
Range("B1").Select
ActiveCell.FormulaR1C1 = "821505000"
Range("C1").Select
ActiveCell.FormulaR1C1 = "1" & "0" & Format(Date, "mm") - 3 & "0" & Format(Date, "mm") - 1
ActiveCell.FormulaR1C1 = "11012"
Range("D1").Select
ActiveCell.FormulaR1C1 = Format(Date, "yyyy")
Range("E1").Select
ActiveCell.FormulaR1C1 = "CGN2005_001_SALDOS_Y_MOVIMIENTOS"
Range("A1").Select
ActiveWindow.SmallScroll Down:=-3
Range("C1").Select
ActiveCell.FormulaR1C1 = "1" & "0" & Format(Date, "mm") - 3 & "0" & Format(Date, "mm") - 1
Range("A2").Select
ActiveCell.FormulaR1C1 = "=+IF(RC[1]<>0,""D"","""")"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A271"), Type:=xlFillDefault
Range("A2:A271").Select
Range("C258").Select
Sheets("Plano").Select
Sheets("Plano").Move
Cells.Select
Selection.NumberFormat = "@"
ActiveWorkbook.SaveAs Filename:="D:\cbedoya\Desktop\F1-IUPB-" & "0" & Format(Date, "mm") - 1 & Format(Date, "yy") & "-Plano.txt", _
FileFormat:=xlText, CreateBackup:=False
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub
