why this code doesn't work?

7

71paolo71

Dear friends
Someone can tell me why the code "wkbk.Close SaveChange:=False doesn'
work" in the macro below?
Is it possible to write the bklist in a different way (more short)?
Thanks in advance

Sub Unisce_file()
bkList = Array("C:\Documents an
Settings\donello\Desktop\MACRO\vendite.xls", _
"C:\Documents and Settings\donello\Desktop\MACRO\ordini.xls", _
"C:\Documents and Settings\donello\Desktop\MACRO\bdg.xls", _
"C:\Documents and Settings\donello\Desktop\MACRO\personale.xls", _
"C:\Documents and Settings\donello\Desktop\MACRO\mdc.xls")
For i = LBound(bkList) To UBound(bkList)
Set wkbk = Workbooks.Open(bkList(i))
If i = LBound(bkList) Then
wkbk.Sheets.Copy
Set wkbk1 = ActiveWorkbook
Else
wkbk.Sheets.Copy After:=wkbk1.Sheets(wkbk1.Sheets.Count)
End If
Next
wkbk1.SaveAs Filename:="C:\Documents an
Settings\donello\Desktop\MACRO\report.xls"
wkbk.Close SaveChange:=False
End Su
 
F

Frank Kabel

Hi
use
wkbk.Close SaveChanges:=False
(you missed an 's'). You may also add the statement
Option Explicit
at the beginning of your module
 
B

Bob Phillips

The argument is SaveChanges not SaveChange.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
P

Pete McCosh

Paolo,

not sure if it's a typo, but the line should read:

wkbk.Close SaveChanges:=false

rather than SaveChange:=False

Cheers, Pete
-----Original Message-----
Dear friends
Someone can tell me why the code "wkbk.Close SaveChange:=False doesn't
work" in the macro below?
Is it possible to write the bklist in a different way (more short)?
Thanks in advance

Sub Unisce_file()
bkList = Array("C:\Documents and
Settings\donello\Desktop\MACRO\vendite.xls", _
"C:\Documents and
Settings\donello\Desktop\MACRO\ordini.xls", _
"C:\Documents and
Settings\donello\Desktop\MACRO\bdg.xls", _
"C:\Documents and
Settings\donello\Desktop\MACRO\personale.xls", _
 
T

Tom Ogilvy

Sub Unisce_file()
sPath = "C:\Documents and Settings\donello\Desktop\MACRO\"
bkList = Array("vendite.xls", _
"ordini.xls", _
"bdg.xls", _
"personale.xls", _
"mdc.xls")
For i = LBound(bkList) To UBound(bkList)
Set wkbk = Workbooks.Open(sPath & bkList(i))
If i = LBound(bkList) Then
wkbk.Sheets.Copy
Set wkbk1 = ActiveWorkbook
Else
wkbk.Sheets.Copy After:=wkbk1.Sheets(wkbk1.Sheets.Count)
End If
Next
wkbk1.SaveAs Filename:=sPath & "report.xls"
wkbk.Close SaveChange:=False
End Sub
 
D

Dana DeLouis

A little off topic, but just to share an idea. Personal preference would be
to factor out the long Directory. Again, just an idea.

Sub Unisce_file()

Const Base As String = "C:\Documents and Settings\donello\Desktop\MACRO\"

bkList = Array("vendite.xls", "ordini.xls", "bdg.xls", "personale.xls",
"mdc.xls")

For i = LBound(bkList) To UBound(bkList)
Set wkbk = Workbooks.Open(Base & bkList(i))

'etc
wkbk1.SaveAs Filename:=Base & "report.xls"

End Sub
 
7

71paolo71

Hi friends
If I use the code "wkbk.Close SaveChanges:=False"
the macro works (no error message) but unfortunately doesn't close th
workbooks. Do I have to use another code?
Someone can help me
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top