
Public Sub aggiorn7()
Dim file41, file42, file43, file44, file45, file46, file47, file48, file49, file50 As String
Dim nwb As Integer
Dim wbnome As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'file "nome1.xls"
file41 = ThisWorkbook.Worksheets("processo").Cells(41, 2).Value
Workbooks.Open file41, UpdateLinks:=False
'file "nome2.xls"
file42 = ThisWorkbook.Worksheets("processo").Cells(42, 2).Value
Workbooks.Open file42, UpdateLinks:=False
'file "nome3.xls"
file43 = ThisWorkbook.Worksheets("processo").Cells(43, 2).Value
Workbooks.Open file43, UpdateLinks:=False
'file "nome4.xls"
file44 = ThisWorkbook.Worksheets("processo").Cells(44, 2).Value
Workbooks.Open file44, UpdateLinks:=False
'file "nome5.xls"
file45 = ThisWorkbook.Worksheets("processo").Cells(45, 2).Value
Workbooks.Open file45, UpdateLinks:=False
'file "nome6.xls"
file46 = ThisWorkbook.Worksheets("processo").Cells(46, 2).Value
Workbooks.Open file46, UpdateLinks:=False
'file "nome7.xls"
file47 = ThisWorkbook.Worksheets("processo").Cells(47, 2).Value
Workbooks.Open file47, UpdateLinks:=False
For nwb = 2 To Workbooks.Count
wbnome = Workbooks.Item(nwb).Name
Workbooks(wbnome).UpdateLink Name:=Workbooks(wbnome).LinkSources
If Workbooks(wbnome).Worksheets("check").Range("test") = 0 Then
Workbooks(wbnome).Close savechanges:=True
Else
MsgBox "Controllare " & wbnome & " ", vbOKOnly
Exit Sub
End If
Next nwb
'istruzione ripetuta aggiungendo "nome2.xls", "nome3.xls"...
'Workbooks("nome1.xls").Activate
'ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources
'Workbooks("nome1.xls").Activate
'If ActiveWorkbook.Worksheets("check").Range("test") = 0 Then
' ActiveWorkbook.Close savechanges:=True
'Else
' MsgBox "Controllare " & ActiveWorkbook.Name & " ", vbOKOnly
' Exit Sub
'End If
Application.ScreenUpdating = True
Application.DisplayAlerts = True
messaggio = MsgBox("Aggiornamento terminato")
End Sub |
Public Sub aggiorn7()
Dim C As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For C = 41 To 47
Workbooks.Open ThisWorkbook.Worksheets("processo").Cells(C, 2), UpdateLinks:=False
With ActiveWorkbook
.UpdateLink Name:=.LinkSources
If .Worksheets("check").Range("test") = 0 Then
.Close savechanges:=True
Else
MsgBox "Controllare " & .Name & " ", vbOKOnly
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Exit Sub
End If
End With
Next C
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox ("Aggiornamento terminato")
End Sub
|
Public Sub aggiorn7()
Dim C As Long
Dim nwb As Integer
Dim wbnome As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'prima apro tutti e sette i file e li aggiorno
For C = 41 To 47
Workbooks.Open ThisWorkbook.Worksheets("processo").Cells(C, 2), UpdateLinks:=False
With ActiveWorkbook
.UpdateLink Name:=.LinkSources
End With
Next C
'dopo l'aggiornamento controllo la cella test
For nwb = 2 To Workbooks.Count
wbnome = Workbooks.Item(nwb).Name
If Workbooks(wbnome).Worksheets("check").Range("test") = 0 Then
Workbooks(wbnome).Close savechanges:=True
Else
MsgBox "Controllare " & wbnome & " ", vbOKOnly
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Exit Sub
End If
Next nwb
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox ("Aggiornamento terminato")
End Sub |
For nwb = 2 To Workbooks.Count
wbnome = Workbooks.Item(nwb).Name
If Workbooks(wbnome).Worksheets("check").Range("test") = 0 Then
Workbooks(wbnome).Close savechanges:=True
Else
MsgBox "Controllare " & wbnome & " ", vbOKOnly
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Exit Sub
End If
Next nwb |
Sub TuttiTranneQuesto()
Dim Wk As Workbook
For Each Wk In Workbooks
If Wk.Name <> ThisWorkbook.Name Then
MsgBox "Questo non è ThisWorkbook: " & Wk.Name
Else
MsgBox "Questo,invece, è ThisWorkbook: " & Wk.Name
End If
Next Wk
End Sub
|
Sub upload_conf()
Dim aLinks As Variant
aLinks = ActiveWorkbook.LinkSources(xlExcelLinks)
Dim uno, due, tre As String
uno = aLinks(3)
uno_file = Split(uno, "")(UBound(Split(uno, "")))
due = aLinks(2)
due_file = Split(due, "")(UBound(Split(due, "")))
tre = aLinks(1)
tre_file = Split(tre, "")(UBound(Split(tre, "")))
' MsgBox uno 'instr
' MsgBox due 'loc
' MsgBox tre 'n2
Dim sPercorso_uno As String, sPercorso_due As String, sPercorso_tre As String
n2_presencev = ThisWorkbook.Worksheets("CONFIGURATOR").Range("n2_presence")
If (n2_presencev = 1) Then
ThisWorkbook.Worksheets("CONFIGURATOR").Range("locpath") = Application.GetOpenFilename(, , "Update " & uno_file)
sPercorso_uno = ThisWorkbook.Worksheets("CONFIGURATOR").Range("locpath")
ThisWorkbook.Worksheets("CONFIGURATOR").Range("locfile") = Split(sPercorso_uno, "")(UBound(Split(sPercorso_uno, "")))
ActiveWorkbook.ChangeLink uno, sPercorso_uno, xlExcelLinks
Else
End If
ThisWorkbook.Worksheets("CONFIGURATOR").Range("instrpath") = Application.GetOpenFilename(, , "Update " & due_file)
sPercorso_due = ThisWorkbook.Worksheets("CONFIGURATOR").Range("instrpath")
ThisWorkbook.Worksheets("CONFIGURATOR").Range("instrfile") = Split(sPercorso_due, "")(UBound(Split(sPercorso_due, "")))
ActiveWorkbook.ChangeLink due, sPercorso_due, xlExcelLinks
loc_indv = ThisWorkbook.Worksheets("CONFIGURATOR").Range("loc_ind")
If (loc_indv = 1) Then
ThisWorkbook.Worksheets("CONFIGURATOR").Range("n2path") = Application.GetOpenFilename(, , "Update " & tre_file)
sPercorso_tre = ThisWorkbook.Worksheets("CONFIGURATOR").Range("n2path")
ThisWorkbook.Worksheets("CONFIGURATOR").Range("n2file") = Split(sPercorso_tre, "")(UBound(Split(sPercorso_tre, "")))
ActiveWorkbook.ChangeLink tre, sPercorso_tre, xlExcelLinks
Else
End If
Application.Calculate
End Sub |
