![]() |
why this code doesn't work?
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 -- Message posted from http://www.ExcelForum.com |
why this code doesn't work?
Try
wkbk.Close SaveChanges:=False note the ending s in SaveChanges. In article , 71paolo71 wrote: Someone can tell me why the code "wkbk.Close SaveChange:=False doesn't work" in the macro below? |
why this code doesn't work?
Hi
use wkbk.Close SaveChanges:=False (you missed an 's'). You may also add the statement Option Explicit at the beginning of your module -- Regards Frank Kabel Frankfurt, Germany 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", _ "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 and Settings\donello\Desktop\MACRO\report.xls" wkbk.Close SaveChange:=False End Sub --- Message posted from http://www.ExcelForum.com/ |
why this code doesn't work?
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) "71paolo71 " wrote in 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", _ "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 and Settings\donello\Desktop\MACRO\report.xls" wkbk.Close SaveChange:=False End Sub --- Message posted from http://www.ExcelForum.com/ |
why this code doesn't work?
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", _ "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 and Settings\donello\Desktop\MACRO\report.xls" wkbk.Close SaveChange:=False End Sub |
why this code doesn't work?
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 -- Regards, Tom Ogilvy "71paolo71 " wrote in 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", _ "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 and Settings\donello\Desktop\MACRO\report.xls" wkbk.Close SaveChange:=False End Sub --- Message posted from http://www.ExcelForum.com/ |
why this code doesn't work?
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 -- Dana DeLouis Using Windows XP & Office XP = = = = = = = = = = = = = = = = = "71paolo71 " wrote in 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", _ "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 and Settings\donello\Desktop\MACRO\report.xls" wkbk.Close SaveChange:=False End Sub --- Message posted from http://www.ExcelForum.com/ |
why this code doesn't work?
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 -- Message posted from http://www.ExcelForum.com |
All times are GMT +1. The time now is 08:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com