LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.links
external usenet poster
 
Posts: 473
Default Running Macros

The body of your macro looks fine to me, as a macro to update the links
in the active workbook (in fact I think I recognise some of the
code<g).

But it shouldn't be Workbook_Open.
No need to involve Access.
You can run the macro from Excel.
Tools / Macro / Run

But first, put it in a normal module in a workbook of your choosing.
Change it from
Private Sub Workbook_Open
to
Sub UpdateActiveWorkbookLinks()

And then add a procedure that will cycle through the workbooks you need
to update. It might look something like this:

Sub ProcessXLSFilesInDirectory()
Dim aFiles() As String, iFile As Integer
Dim stFile As String, vFile As Variant
Dim stDirectory As String

' first build an array of the files and then process them
' this is because you may upset the Dir function if you save a file

stDirectory = "D:\TEMP\" ' name of directory to look in
' use Dir function to find XLS files in Directory
stFile = Dir(stDirectory & "*.XLS")
If stFile = "" Then Exit Sub ' no files to process
Do While stFile < ""
' add to array of files
iFile = iFile + 1
' add one element to the array
ReDim Preserve aFiles(1 To iFile)
aFiles(iFile) = stFile
stFile = Dir() ' gets next file
Loop

' now process the files
For Each vFile In aFiles
Workbooks.Open stDirectory & vFile
UpdateActiveWorkbookLinks
Workbooks(vFile).Close saveChanges:=False
Next vFile

End Sub

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running macros without lowering security Chip Smith Excel Discussion (Misc queries) 2 May 4th 06 07:56 PM
Anyone have troubles running 2003 macros in 2000 version of Excel Jim Excel Discussion (Misc queries) 0 April 19th 06 02:15 PM
Running macros when Excel starts up Solly Excel Discussion (Misc queries) 1 July 13th 05 11:38 AM
Problem with running Macros Mark Alex Excel Discussion (Misc queries) 1 May 17th 05 02:28 PM
HELP - Running Macros in VBA Louise New Users to Excel 7 April 6th 05 03:21 PM


All times are GMT +1. The time now is 02:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"