Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Problème macro sur un autre poste

1 réponse
Avatar
Walt51
Bonjour

Voici mon problème :
Sur mon poste (UT10) j'ai créer un fichier Excel 2003 SP3 (intitulé: Suivi de commandes) dans lequel j'ai réalisé 2 macros en VBA (principalement en utilisant la fonction "enregistrer")
Sur mon poste, j'exécute ces macros un cliquant sur deux boutons. (un bouton par macro)
Tout fonctionne bien sur mon poste.
Ce fichier (Suivi de commandes) est enregistré sur le réseau et est donc utilisable (et c'est ma volontée) par tous les postes ayant accès au réseau.
Le problème est que sur les autres poste je n'arrive pas à exécuter les macros.

Mon problème se décompose alors en deux parties car j'ai un problème propre à chaque macros.

La première macro me permet de copier un certain nombre de cellules de la feuille "Création de Commande" située dans mon fichier " Suivi de commandes " dans un nouveau fichier, ce fichier est alors enregistré automatiquement grâce a cette macro.

Sur les autres postes, lorsque j'exécute cette macro j'obtiens le message suivant:
"Erreur de compilation : Projet ou bibliothèque introuvable"
J'ai donc regardé dans l'éditeur VBA, il y a 2 références manquantes mais je ne peux pas les décocher car
"Impossible de supprime de control en cours d'utilisation"
Les 2 référence manquantes sont: "Microsoft Windows Common Controls 6.0 (SP6)" et "Microsoft Office Web Components 11.0"


La deuxième macro me permet de copier un certain nombre de cellules de la feuille "Création de Commande" située dans mon fichier " Suivi de commandes " dans la feuille "HISTORIQUE DES COMMANDES" dans ce même fichier.
Sur les autres postes, lorsque j'exécute cette macro j'obtiens le message suivant:
"Erreur 40036, défini par l'application ou par l'objet" => Je clique "Débogage" => Dans l'éditeur VBA, la première ligne " Sheets ("Création de Commande").select " est surlignée en jaune.

Si quelqu'un à des bonne idées...
Walt


Voici la macro 1

Sub SauvCommExl()
'
' SauvCommExl Macro
' Macro enregistrée le 28/08/2013 par UT10
'

'
Range("A1:E1000").Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows("SUIVI COMMANDES.xls").Activate
Selection.Copy
ActiveWindow.ActivateNext
Range("A1:E1000").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWindow.DisplayGridlines = False
ActiveWindow.View = xlPageBreakPreview
Columns("A:A").Select
Selection.ColumnWidth = 20
Columns("B:B").Select
Selection.ColumnWidth = 45
Columns("C:C").Select
Selection.ColumnWidth = 8
Columns("D:D").Select
Selection.ColumnWidth = 14
Columns("E:E").Select
Selection.ColumnWidth = 14
ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
Set ActiveSheet.HPageBreaks(1).Location = Range("A64")
ActiveWindow.SmallScroll Down:=56
Set ActiveSheet.HPageBreaks(2).Location = Range("A127")
ActiveWindow.SmallScroll Down:=-8
Set ActiveSheet.HPageBreaks(2).Location = Range("A64")
ActiveWindow.SmallScroll Down:=16
Set ActiveSheet.HPageBreaks(2).Location = Range("A64")
ActiveWindow.SmallScroll Down:=72
ActiveSheet.PageSetup.PrintArea = "$A$1:$E$63"
Windows("SUIVI COMMANDES.xls").Activate
ActiveSheet.Shapes("Picture 4").Select
Selection.Copy
ActiveWindow.ActivateNext
Range("B12").Select
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft -97.5
Selection.ShapeRange.IncrementTop -48#
Windows("SUIVI COMMANDES.xls").Activate
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveSheet.Shapes("Button 139").Select
Selection.Copy
ActiveWindow.ActivateNext
Range("I22").Select
ActiveSheet.Buttons.Add(1422.75, 231, 63.75, 65.25).Select
ActiveSheet.Paste
Selection.OnAction = "'SUIVI COMMANDES.xls'!ImprPDF"
ActiveSheet.Shapes("Button 2").Select
Selection.Delete
Windows("SUIVI COMMANDES.xls").Activate
Range("N9").Select
Selection.Copy
ActiveWindow.ActivateNext
Range("H4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("H4").Select
Selection.Locked = False
Selection.FormulaHidden = False
Windows("SUIVI COMMANDES.xls").Activate
Range("J8").Select
Selection.Copy
ActiveWindow.ActivateNext
Range("H1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWorkbook.SaveAs Filename:="Y:BASE DOCUMENTBASE TECHNIQUECOMMANDES Excel" & [H1] & ".xls"
Range("H1").Select
Application.CutCopyMode = False
Selection.ClearContents
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("B34").Select
ActiveWorkbook.Save
Windows("SUIVI COMMANDES.xls").Activate
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveWindow.ActivateNext
End Sub


Voici la macro 2

Sub CopiHistoCommande()
'
' CopiHistoCommande Macro
' Macro enregistrée le 21/08/2013 par UT10
'

'
Sheets("Création de Commande").Select
Range("N5:AC5").Select
Selection.Copy
Range("N6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("N7").Select
Application.CutCopyMode = False
Range("N5:AC5").Select
Selection.Copy
Range("N6:AC6").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("AA22").Select
Sheets("HISTORIQUE DES COMMANDES").Select
ActiveSheet.Unprotect
Rows("2:2").Select
Range("E2").Activate
Selection.Insert Shift:=xlDown
Sheets("Création de Commande").Select
Range("N6:AC6").Select
Selection.Copy
Sheets("HISTORIQUE DES COMMANDES").Select
Range("E2").Select
ActiveWindow.LargeScroll ToRight:=-1
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.Font.Bold = False
Range("B2").Select
Selection.NumberFormat = "m/d/yyyy"
Columns("C:C").EntireColumn.AutoFit
Selection.Copy
Range("D2").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Columns("D:D").EntireColumn.AutoFit
Range("I2").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("J2").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
Range("O2").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("O20").Select
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
Range("P2").Select
Selection.Cut Destination:=Range("T2")
Range("P2").Select
ActiveCell.FormulaR1C1 = "=HYPERLINK(RC[4])"
End With
Range("P3").Select
Columns("O:O").EntireColumn.AutoFit
Range("T1").Select
Selection.Copy Destination:=Range("Q2")
Range("A3:Q3").Select
Range("Q3").Activate
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("T2").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
Sheets("Création de Commande").Select
Range("N6:AC6").Select
Selection.ClearContents
Sheets("HISTORIQUE DES COMMANDES").Select
End Sub

1 réponse

Avatar
walt51
Le mardi 03 Septembre 2013 à 10:08 par Walt51 :
Bonjour

Voici mon problème :
Sur mon poste (UT10) j'ai créer un fichier Excel 2003 SP3
(intitulé: Suivi de commandes) dans lequel j'ai réalisé 2
macros en VBA (principalement en utilisant la fonction
"enregistrer")
Sur mon poste, j'exécute ces macros un cliquant sur deux boutons. (un
bouton par macro)
Tout fonctionne bien sur mon poste.
Ce fichier (Suivi de commandes) est enregistré sur le réseau et
est donc utilisable (et c'est ma volontée) par tous les postes ayant
accès au réseau.
Le problème est que sur les autres poste je n'arrive pas à
exécuter les macros.

Mon problème se décompose alors en deux parties car j'ai un
problème propre à chaque macros.

La première macro me permet de copier un certain nombre de cellules de
la feuille "Création de Commande" située dans mon
fichier " Suivi de commandes " dans un nouveau fichier, ce fichier
est alors enregistré automatiquement grâce a cette macro.

Sur les autres postes, lorsque j'exécute cette macro j'obtiens le
message suivant:
"Erreur de compilation : Projet ou bibliothèque introuvable"
J'ai donc regardé dans l'éditeur VBA, il y a 2
références manquantes mais je ne peux pas les décocher
car
"Impossible de supprime de control en cours d'utilisation"
Les 2 référence manquantes sont: "Microsoft Windows Common
Controls 6.0 (SP6)" et "Microsoft Office Web Components 11.0"


La deuxième macro me permet de copier un certain nombre de cellules de
la feuille "Création de Commande" située dans mon
fichier " Suivi de commandes " dans la feuille "HISTORIQUE DES
COMMANDES" dans ce même fichier.
Sur les autres postes, lorsque j'exécute cette macro j'obtiens le
message suivant:
"Erreur 40036, défini par l'application ou par l'objet" =>
Je clique "Débogage" => Dans l'éditeur VBA, la
première ligne " Sheets ("Création de
Commande").select " est surlignée en jaune.

Si quelqu'un à des bonne idées...
Walt


Voici la macro 1

Sub SauvCommExl()
'
' SauvCommExl Macro
' Macro enregistrée le 28/08/2013 par UT10
'

'
Range("A1:E1000").Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks
_
:úlse, Transpose:úlse
Application.CutCopyMode = False
Windows("SUIVI COMMANDES.xls").Activate
Selection.Copy
ActiveWindow.ActivateNext
Range("A1:E1000").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:úlse, Transpose:úlse
Application.CutCopyMode = False
ActiveWindow.DisplayGridlines = False
ActiveWindow.View = xlPageBreakPreview
Columns("A:A").Select
Selection.ColumnWidth = 20
Columns("B:B").Select
Selection.ColumnWidth = 45
Columns("C:C").Select
Selection.ColumnWidth = 8
Columns("D:D").Select
Selection.ColumnWidth = 14
Columns("E:E").Select
Selection.ColumnWidth = 14
ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
Set ActiveSheet.HPageBreaks(1).Location = Range("A64")
ActiveWindow.SmallScroll Down:V
Set ActiveSheet.HPageBreaks(2).Location = Range("A127")
ActiveWindow.SmallScroll Down:=-8
Set ActiveSheet.HPageBreaks(2).Location = Range("A64")
ActiveWindow.SmallScroll Down:
Set ActiveSheet.HPageBreaks(2).Location = Range("A64")
ActiveWindow.SmallScroll Down:r
ActiveSheet.PageSetup.PrintArea = "$A$1:$E$63"
Windows("SUIVI COMMANDES.xls").Activate
ActiveSheet.Shapes("Picture 4").Select
Selection.Copy
ActiveWindow.ActivateNext
Range("B12").Select
ActiveSheet.Paste
Selection.ShapeRange.IncrementLeft -97.5
Selection.ShapeRange.IncrementTop -48#
Windows("SUIVI COMMANDES.xls").Activate
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveSheet.Shapes("Button 139").Select
Selection.Copy
ActiveWindow.ActivateNext
Range("I22").Select
ActiveSheet.Buttons.Add(1422.75, 231, 63.75, 65.25).Select
ActiveSheet.Paste
Selection.OnAction = "'SUIVI COMMANDES.xls'!ImprPDF"
ActiveSheet.Shapes("Button 2").Select
Selection.Delete
Windows("SUIVI COMMANDES.xls").Activate
Range("N9").Select
Selection.Copy
ActiveWindow.ActivateNext
Range("H4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks
_
:úlse, Transpose:úlse
Range("H4").Select
Selection.Locked = False
Selection.FormulaHidden = False
Windows("SUIVI COMMANDES.xls").Activate
Range("J8").Select
Selection.Copy
ActiveWindow.ActivateNext
Range("H1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks
_
:úlse, Transpose:úlse
ActiveWorkbook.SaveAs Filename:="Y:BASE DOCUMENTBASE
TECHNIQUECOMMANDES Excel" & [H1] & ".xls"
Range("H1").Select
Application.CutCopyMode = False
Selection.ClearContents
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("B34").Select
ActiveWorkbook.Save
Windows("SUIVI COMMANDES.xls").Activate
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveWindow.ActivateNext
End Sub


Voici la macro 2

Sub CopiHistoCommande()
'
' CopiHistoCommande Macro
' Macro enregistrée le 21/08/2013 par UT10
'

'
Sheets("Création de Commande").Select
Range("N5:AC5").Select
Selection.Copy
Range("N6").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks
_
:úlse, Transpose:úlse
Range("N7").Select
Application.CutCopyMode = False
Range("N5:AC5").Select
Selection.Copy
Range("N6:AC6").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:úlse, Transpose:úlse
Application.CutCopyMode = False
Range("AA22").Select
Sheets("HISTORIQUE DES COMMANDES").Select
ActiveSheet.Unprotect
Rows("2:2").Select
Range("E2").Activate
Selection.Insert Shift:=xlDown
Sheets("Création de Commande").Select
Range("N6:AC6").Select
Selection.Copy
Sheets("HISTORIQUE DES COMMANDES").Select
Range("E2").Select
ActiveWindow.LargeScroll ToRight:=-1
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks
_
:úlse, Transpose:úlse
Selection.Font.Bold = False
Range("B2").Select
Selection.NumberFormat = "m/d/yyyy"
Columns("C:C").EntireColumn.AutoFit
Selection.Copy
Range("D2").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:úlse, Transpose:úlse
Application.CutCopyMode = False
Columns("D:D").EntireColumn.AutoFit
Range("I2").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("J2").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
Range("O2").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("O20").Select
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
Range("P2").Select
Selection.Cut Destination:=Range("T2")
Range("P2").Select
ActiveCell.FormulaR1C1 = "=HYPERLINK(RC[4])"
End With
Range("P3").Select
Columns("O:O").EntireColumn.AutoFit
Range("T1").Select
Selection.Copy Destination:=Range("Q2")
Range("A3:Q3").Select
Range("Q3").Activate
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("T2").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
_
, AllowSorting:=True, AllowFiltering:=True
Sheets("Création de Commande").Select
Range("N6:AC6").Select
Selection.ClearContents
Sheets("HISTORIQUE DES COMMANDES").Select
End Sub


Evolution:
Concernant la macro 2, le problème semble résolu en faisant un peu de ménage.
En revanche, pour la macro 1 cela ne fonctionne toujours pas sur les autres postes.
Erreur compilation...
Au niveau de la ligne:
ActiveWorkbook.SaveAs Filename:="Y:BASE DOCUMENTBASE TECHNIQUECOMMANDES Excel" & [H1] & ".xls"
Le "H1" est surligné en jaune. Je l'ai remplacé par "Test" et ça a fonctionné.
Le problème est que je souhait enregistrer mon fichier sous le nom logé dans la case H1...