A
asburypark98
Hi,
the code I inserted below, has got a problem.
It refers to the initially loop.
My aim is: open files, update them by DDE connection,
save them.
I'd like to use a loop procedure (or something
similar), that opens files one by one. So every
file is opened, then updated, then saved.
But loop goes fast and opens all files at the same
time and the code runs wrong. I tried to use
Application.OnTime method to manage the "timing"
about the opening of the files, but I hadn't
good results.
Do you know something else to solve the problem
or tell me where my code is wrong?
I also used "inputbox" instead of the loop;
but "inputbox" is good if I've got only some file..
if I've got many files, it takes me more time.
Thank you very much for your help,
deborah
'==========================================
Option Explicit
Dim WB As Workbook
Dim arrFiles()
Dim sFile As String
Dim i
Dim A
'------------------------------------------
Sub verification()
Dim sPath As String
Dim File As String
sPath = "C:\Files\"
arrFiles = Array("Alfa", "Beta")
For i = 0 To 1
sFile = Dir(sPath & arrFiles(i) & "*.xls")
Workbooks.Open (sPath & arrFiles(i))
Set WB = ActiveWorkbook
LinkList
End If
Next i
End Sub
'-----------------------------------------------
Private Sub LinkList()
Dim Links As Variant
Links = WB.LinkSources(xlOLELinks)
If Not IsEmpty(Links) Then
For A = 1 To UBound(Links)
WB.SetLinkOnData Links(A), "LinkChange"
Next A
Else
MsgBox "This workbook does not contain any links" & _
"to other workbooks"
End If
End Sub
'------------------------------------------------
Private Sub LinkChange()
'''''
End Sub
'------------------------------------------------
the code I inserted below, has got a problem.
It refers to the initially loop.
My aim is: open files, update them by DDE connection,
save them.
I'd like to use a loop procedure (or something
similar), that opens files one by one. So every
file is opened, then updated, then saved.
But loop goes fast and opens all files at the same
time and the code runs wrong. I tried to use
Application.OnTime method to manage the "timing"
about the opening of the files, but I hadn't
good results.
Do you know something else to solve the problem
or tell me where my code is wrong?
I also used "inputbox" instead of the loop;
but "inputbox" is good if I've got only some file..
if I've got many files, it takes me more time.
Thank you very much for your help,
deborah
'==========================================
Option Explicit
Dim WB As Workbook
Dim arrFiles()
Dim sFile As String
Dim i
Dim A
'------------------------------------------
Sub verification()
Dim sPath As String
Dim File As String
sPath = "C:\Files\"
arrFiles = Array("Alfa", "Beta")
For i = 0 To 1
sFile = Dir(sPath & arrFiles(i) & "*.xls")
Workbooks.Open (sPath & arrFiles(i))
Set WB = ActiveWorkbook
LinkList
End If
Next i
End Sub
'-----------------------------------------------
Private Sub LinkList()
Dim Links As Variant
Links = WB.LinkSources(xlOLELinks)
If Not IsEmpty(Links) Then
For A = 1 To UBound(Links)
WB.SetLinkOnData Links(A), "LinkChange"
Next A
Else
MsgBox "This workbook does not contain any links" & _
"to other workbooks"
End If
End Sub
'------------------------------------------------
Private Sub LinkChange()
'''''
End Sub
'------------------------------------------------