M
Martyn
I have modified a code from this NG to help me copy my nick into a number of
*.xls files in a spesific DIR. But when activated it only copies my nick to
the file where the macro resides and not on the "target" files. I know I'm
doing something wrong here with this "active document" part, but can't
figure what the correct syntax should be. Any help is appreciated...
--------------------------------
Sub Insert()
Dim mesaj As String
Dim FilesArray() As String, FileCounter As Integer
Dim FName As String, LoopCounter As Integer
FName = Dir("c:\my documents\test\*.xls")
Do While FName <> ""
FileCounter = FileCounter + 1
ReDim Preserve FilesArray(1 To FileCounter)
FilesArray(FileCounter) = FName
FName = Dir()
Loop
If FileCounter > 0 Then
Application.ScreenUpdating = False
For LoopCounter = 1 To FileCounter
Workbooks.Open "c:\my documents\test\" &
FilesArray(LoopCounter), False
With ActiveSheet
Sheet1.Range("O1").Value = "Martyn"
ActiveWorkbook.Save
ActiveWorkbook.Close
Next
End If
End Sub
*.xls files in a spesific DIR. But when activated it only copies my nick to
the file where the macro resides and not on the "target" files. I know I'm
doing something wrong here with this "active document" part, but can't
figure what the correct syntax should be. Any help is appreciated...
--------------------------------
Sub Insert()
Dim mesaj As String
Dim FilesArray() As String, FileCounter As Integer
Dim FName As String, LoopCounter As Integer
FName = Dir("c:\my documents\test\*.xls")
Do While FName <> ""
FileCounter = FileCounter + 1
ReDim Preserve FilesArray(1 To FileCounter)
FilesArray(FileCounter) = FName
FName = Dir()
Loop
If FileCounter > 0 Then
Application.ScreenUpdating = False
For LoopCounter = 1 To FileCounter
Workbooks.Open "c:\my documents\test\" &
FilesArray(LoopCounter), False
With ActiveSheet
Sheet1.Range("O1").Value = "Martyn"
ActiveWorkbook.Save
ActiveWorkbook.Close
Next
End If
End Sub