View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
ugoveri ugoveri is offline
external usenet poster
 
Posts: 5
Default Excel 2007 problem with macros

The error is:

This workbook is corrupted. This may be the result of program failure, or it
may have been intentionally corrupted by a malicious source. the Open and
Repair feature may be able to recover the contents of this document. Do not
use Open and Repair on this file if the file is not from a trusted source. Do
you want to use Open and Repair on this file?

If I choose Yes it starts repairing and once starting to calculate it get's
stuck...

The macros well... Here they go:

Sub Apaga()
Application.GoTo Reference:="Insere"
Selection.ClearContents
Selection.ClearComments
Range("I10").Activate
End Sub
Sub DaNome()
a = Range("g2")
For i = 2 To Sheets.Count
If Sheets(i).Name = a Then
Range("i10").Select
End
End If
Next i
ActiveSheet.Name = a
Range("i10").Activate
End Sub
Sub Protege()
For i = 1 To Sheets.Count
Sheets(i).Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFiltering:=True
ActiveSheet.EnableSelection = xlNoRestrictions
Next i
i = 1
Sheets(i).Activate
Range("i10").Activate
End Sub
Sub Desprotege()
For i = 1 To Sheets.Count
Sheets(i).Unprotect
Next i
i = 1
Sheets(i).Select
Range("i10").Select
End Sub

Sub NovaFolha()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim array_aux() As Variant
ActiveSheet.Activate
a = ActiveSheet.Name
B = Range("f4")
Sheets(a).Copy After:=Sheets(a)
C = ActiveSheet.Name
Sheets(C).Activate
On Error GoTo Fim
Range("F3") = Range("I4")
Sheets(C).Name = B
C = ActiveSheet.Name
GoTo Fim
Fim:
Apaga
array_aux = Sheets(a).Range("AM11:AM34").Value
Sheets(C).Range("AM11:AM34").Value = array_aux
array_aux = Sheets(a).Range("AN10:AN34").Value
Sheets(C).Range("AO10:AO34").Value = array_aux
array_aux = Sheets(a).Range("AP10:AP34").Value
Sheets(C).Range("AP10:AP34").Value = array_aux
array_aux = Sheets(a).Range("AQ10:AQ34").Value
Sheets(C).Range("AR10:AR34").Value = array_aux
Sheets(a).Activate
Range("I10").Activate
Sheets(C).Activate
Range("I10").Select
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub


Function num_mov(in_out_cont As String, asterix As String, descricao As
String) As Variant
Dim valor As String
If in_out_cont = "in" Then
If LCase(descricao) Like "*poupança*" Or LCase(descricao) Like
"*ordem*" Then
If asterix = "*" Then valor = "2a" Else valor = "2"
Else
If asterix = "*" Then valor = "1a" Else valor = 1
End If
ElseIf in_out_cont = "out" Then
If LCase(descricao) Like "*poupança*" Or LCase(descricao) Like
"*ordem*" Then
If asterix = "*" Then valor = "2a" Else valor = "2"
ElseIf LCase(descricao) Like "*formação*" Or LCase(descricao) Like
"*livros*" Or _
LCase(descricao) Like "*mestrado*" Then
If asterix = "*" Then valor = "3a" Else valor = "3"
Else
If asterix = "*" Then valor = "1a" Else valor = "1"
End If
ElseIf in_out_cont = "cont" Then
If LCase(descricao) Like "*poupança*" Then
valor = "1"
ElseIf LCase(descricao) Like "*ordem*" Then
valor = "2"
Else
valor = "3"
End If
End If
num_mov = valor
End Function

And I also have a combobox in each sheet:

Private Sub ComboBox1_Change()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
a = ActiveSheet.Name
B = Range("f2")
On Error GoTo Fim
Sheets(a).Name = B
GoTo Fim
Fim:
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

Anyway, if I do not convert the file to 2007 format it works just fine... I
have not tried recording any macro in 2007 and reopening it, but with the
ones already existing I always get this same error... I thought it was only
with udf, but as shown with the macros listed before, with subroutines it
happened also...

Hope this information can help...

Thanks in advance,