ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open, allow link updates, and Save (https://www.excelbanter.com/excel-programming/328916-open-allow-link-updates-save.html)

CLR

Open, allow link updates, and Save
 
Hi All..........

If someone would be so kind, I am in need of a macro that will reside in a
Master WorkBook and when run as a "before save event", would open and allow
update all links therein, and save, one at a time, all other .xls files in
the same directory whose filename start with "XY-" no
quotes............exact quantity of the files is unknown, but may be 10 to
100. Any other files in the directory, including the Master, not having the
leading "XY-" in their filename are not to be affected.


TIA..........

Vaya con Dios,
Chuck, CABGx3





Tom Ogilvy

Open, allow link updates, and Save
 
Dim v() as String
Dim sName as String
Dim i as Long, j as Long
redim v(1 to 100)

sName = dir( _
thisworkbook.Path & "\XY-*.xls")
i = 0
Do while sName < ""
i = i + 1
v(i) = thisworkbook.Path & "\" & sname
sName = Dir()
Loop
redim preserve v(1 to i)
for j = 1 to ubound(v)
set bk = workbooks.Open( _
FileName:=v(j), UpdateLinks:=3)
bk.close Savechanges:=True
Next

Untested, but this should be something like what you are looking for (as I
understand you question and it wasn't real clear). Assumes master does not
start with XY-



--
Regards,
Tom Ogilvy



"CLR" wrote in message
...
Hi All..........

If someone would be so kind, I am in need of a macro that will reside in a
Master WorkBook and when run as a "before save event", would open and

allow
update all links therein, and save, one at a time, all other .xls files in
the same directory whose filename start with "XY-" no
quotes............exact quantity of the files is unknown, but may be 10 to
100. Any other files in the directory, including the Master, not having

the
leading "XY-" in their filename are not to be affected.


TIA..........

Vaya con Dios,
Chuck, CABGx3







CLR

Open, allow link updates, and Save
 
Unbelieveably cool.............it works perfectly.........

You are a Prince among us mortals Tom..........

Thank you ever so much.......

Vaya con Dios,
Chuck, CABGx3



"Tom Ogilvy" wrote in message
...
Dim v() as String
Dim sName as String
Dim i as Long, j as Long
redim v(1 to 100)

sName = dir( _
thisworkbook.Path & "\XY-*.xls")
i = 0
Do while sName < ""
i = i + 1
v(i) = thisworkbook.Path & "\" & sname
sName = Dir()
Loop
redim preserve v(1 to i)
for j = 1 to ubound(v)
set bk = workbooks.Open( _
FileName:=v(j), UpdateLinks:=3)
bk.close Savechanges:=True
Next

Untested, but this should be something like what you are looking for (as I
understand you question and it wasn't real clear). Assumes master does

not
start with XY-



--
Regards,
Tom Ogilvy



"CLR" wrote in message
...
Hi All..........

If someone would be so kind, I am in need of a macro that will reside in

a
Master WorkBook and when run as a "before save event", would open and

allow
update all links therein, and save, one at a time, all other .xls files

in
the same directory whose filename start with "XY-" no
quotes............exact quantity of the files is unknown, but may be 10

to
100. Any other files in the directory, including the Master, not having

the
leading "XY-" in their filename are not to be affected.


TIA..........

Vaya con Dios,
Chuck, CABGx3










All times are GMT +1. The time now is 07:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com