LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default ActiveWorkbook.Close True

Hi There,

I am using underneath sub to loop through files in a directory ...
I would like to run a macro on every workbook :"'Sige.xls'!Macro2"
And then save the changes on each workbook ...this last part does not
work ...
Anybody who can point me out?

Best Regards Sige

Sub LoopFiles()

Application.ScreenUpdating = False

Dim vFiles()
Dim vFileName As Variant
Dim i As Long
Dim myfile As String
Dim j As Long

MsgBox "At next dialog box, indicate at least one Excel " _
& "workbook file in the directory where all the files in " _
& "the same will be done."

vFileName = Application.GetSaveAsFilename(, "Excel files(*.XLS),
*.xls")

If vFileName = False Then Exit Sub

If MsgBox("All Excel workbook file (*.xls) in " _
& CurDir & " will be done now automatically. OK?", vbOKCancel)
_
= vbCancel Then Exit Sub

myfile = Dir("*.XLS") 'just one file

If myfile = "" Then
MsgBox "no files found"
Exit Sub
End If


Do While myfile < ""
i = i + 1
ReDim Preserve vFiles(1 To i)
vFiles(i) = myfile
myfile = Dir()
Loop

For i = LBound(vFiles) To UBound(vFiles)
Workbooks.Open FileName:=vFiles(i)
' Subroutine.
Application.Run "'Sige.xls'!Macro2"
Workbooks.Close FileName:=vFiles(i) True '<======

Next
MsgBox UBound(vFiles) - LBound(vFiles) + 1 & _
" workbook files were(was) done."

Application.ScreenUpdating = True
End Sub

 
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
ActiveWorkbook.Close (False) stefan via OfficeKB.com Excel Programming 3 July 12th 05 12:42 AM
ActiveWorkbook.Close dallas Excel Programming 0 November 3rd 04 06:27 PM
ActiveWorkbook.Close dallas Excel Programming 2 November 3rd 04 05:56 PM
ActiveWorkbook.EnvelopeVisible = True DFox Excel Programming 3 October 7th 04 07:51 PM
ActiveWorkbook.Close Matthew[_9_] Excel Programming 4 November 13th 03 02:48 AM


All times are GMT +1. The time now is 08:15 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"