Probléme macro - changement du nom du fichier

porcinet95

XLDnaute Nouveau
Bonjour,

Je n'arrive pas à résoudre le problème suivant :

J'ai crée une macro qui me permet de copier des données d'un fichier A vers un autre fichier B.
Le problème est que le fichier A est un fichier type
je suis amené à creer plusieurs fichier A en changeant leur nom mais quand je change le nom de mon fichier A, il m'indique une erreur
Il ne me change pas le nom dans la macro

Help

Merci
 

Pierrot93

XLDnaute Barbatruc
Re : Probléme macro - changement du nom du fichier

Bonsoir,

sans voir le code utilisé difficile, mais essaye peut être de remplacer "workbooks("nomclasseur") par "thisworkbook"... bien sur si le code est dans le classeur concerné...

bonne soirée
@+
 

porcinet95

XLDnaute Nouveau
Re : Probléme macro - changement du nom du fichier

Voici ma macro

Je débute en VBA alors je sais que c'est pas terrible

Sub Enregist_Histo()
'
' Enregist_Histo Macro
' Macro enregistrée le 16/04/2010 par
'

'
Range("W4").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Rows("3:7").Select
Range("M3").Activate
Selection.Insert Shift:=xlDown
Range("R13:Ae17").Select
Selection.Copy
Range("A3").Select
ActiveSheet.Paste
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("A18:p22").Select
Application.CutCopyMode = False
Selection.Copy
Windows("thisworkbook").Activate
Range("N3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("R19").Select
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
Windows("thisworkbook").Activate
Range("M4:N5").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Historique essai pompe OPTIMEX.xls").Activate
Range("AE3:AE7").Select
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
ActiveCell.FormulaR1C1 = ""
Range("AF17").Select
Windows("thisworkbook").Activate
Range("M8").Select
Selection.Copy
Application.WindowState = xlMinimized
Windows("Historique essai pompe OPTIMEX.xls").Activate
Range("AF3:AF7").Select
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Windows("Relevé général essais - BFXXX.xls").Activate
Range("M7").Select
Selection.Copy
Windows("Historique essai pompe OPTIMEX.xls").Activate
Range("AG3:AG6").Select
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("AG3:AG7").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Selection.UnMerge
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("AE18").Select
Windows("Relevé général essais - BFXXX.xls").Activate
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 14
Range("Z6").Select
End Sub
 

porcinet95

XLDnaute Nouveau
Re : Probléme macro - changement du nom du fichier

Oui je sais c'est bien compliquer pour si peux en faite
Je souhaite couper/coller des cellules d'un fichier vers un autre fichier avec ouverture de celui ci, insertion de ligne et retour vers le premier.
Comme je ne savais pas très bien ce que je voulais, c'est un peu brouillon.

Mais je suis bloquer avec ce problème
 

Discussions similaires

Membres actuellement en ligne

Aucun membre en ligne actuellement.

Statistiques des forums

Discussions
312 611
Messages
2 090 226
Membres
104 453
dernier inscrit
benjiii88