Macro imprim incompabilité excel 2010
Résolu
Bonjour,
j'ai une macro qui fonctionne tres bien avec excel 2007 mais qui bloque avec 2010
Sub Imprim(nom As String)
Dim inCalculationMode As Integer
Application.ScreenUpdating = False
inCalculationMode = Application.Calculation
Application.Calculation = xlCalculationManual
With Sheets("conges")
x = 0
y = Application.Match(nom, .Rows(7), 0) - 1
End With
For Each Sh In Sheets
If Sh.Name = "Temp" Then
Application.DisplayAlerts = False
Sh.Delete
Application.DisplayAlerts = True
End If
Next Sh
Sheets.Add
ActiveSheet.Name = "Temp"
With Sheets("Conges")
[conges!A6:D37].Offset(x, y).Copy [B1]
For Each c In [H1:K32]
If c.Value = 0 Then c.Value = ""
Next c
Columns(1).ColumnWidth = 18.57
Columns(2).ColumnWidth = 18.57
Columns(3).ColumnWidth = 5.86
Columns(4).ColumnWidth = 5.86
End With
[B1:G1].EntireColumn.AutoFit
[1:5].Insert
[A1:G1].Merge
[H1:K32].HorizontalAlignment = xlCenter
[A1].HorizontalAlignment = xlCenter
[A1] = "le " & Format(Date, "DD MMMM YYYY")
[A1].Font.Size = 12
[A39] = "le salarié"
[G39] = "la direction"
[A39:G39].Font.Size = 12
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.7)
.RightMargin = Application.InchesToPoints(0.7)
.TopMargin = Application.InchesToPoints(2.38)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
End With
DoEvents
Application.ScreenUpdating = True
ActiveSheet.PrintPreview
'ActiveSheet.PrintOut
Application.DisplayAlerts = False
Sheets("Temp").Delete
Application.DisplayAlerts = True
Application.Calculation = inCalculationMode
End Sub
e
j'ai une macro qui fonctionne tres bien avec excel 2007 mais qui bloque avec 2010
Sub Imprim(nom As String)
Dim inCalculationMode As Integer
Application.ScreenUpdating = False
inCalculationMode = Application.Calculation
Application.Calculation = xlCalculationManual
With Sheets("conges")
x = 0
y = Application.Match(nom, .Rows(7), 0) - 1
End With
For Each Sh In Sheets
If Sh.Name = "Temp" Then
Application.DisplayAlerts = False
Sh.Delete
Application.DisplayAlerts = True
End If
Next Sh
Sheets.Add
ActiveSheet.Name = "Temp"
With Sheets("Conges")
[conges!A6:D37].Offset(x, y).Copy [B1]
For Each c In [H1:K32]
If c.Value = 0 Then c.Value = ""
Next c
Columns(1).ColumnWidth = 18.57
Columns(2).ColumnWidth = 18.57
Columns(3).ColumnWidth = 5.86
Columns(4).ColumnWidth = 5.86
End With
[B1:G1].EntireColumn.AutoFit
[1:5].Insert
[A1:G1].Merge
[H1:K32].HorizontalAlignment = xlCenter
[A1].HorizontalAlignment = xlCenter
[A1] = "le " & Format(Date, "DD MMMM YYYY")
[A1].Font.Size = 12
[A39] = "le salarié"
[G39] = "la direction"
[A39:G39].Font.Size = 12
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.7)
.RightMargin = Application.InchesToPoints(0.7)
.TopMargin = Application.InchesToPoints(2.38)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
End With
DoEvents
Application.ScreenUpdating = True
ActiveSheet.PrintPreview
'ActiveSheet.PrintOut
Application.DisplayAlerts = False
Sheets("Temp").Delete
Application.DisplayAlerts = True
Application.Calculation = inCalculationMode
End Sub
e