Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
I am trying to export 1 sheet to a new workbook with a specific save as
filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
Try something like
Dim FName As Variant FName = Application.GetSaveAsFilename( _ InitialFileName:="Book1.xlsm", _ Filefilter:="Excel Files (*.xlsm),*.xlsm") If FName = False Then ' user cancelled Exit Sub End If -- Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group Pearson Software Consulting, LLC www.cpearson.com (email on web site) "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
Hi ZWatts773
Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
Ron thanks for the info, these macros work great.
The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
Hi ZWatts773
See this example to save each sheet as a workbook http://www.rondebruin.nl/copy6.htm You can change the file name in this part of the code With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Name & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With What are the names of the week sheets ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Ron thanks for the info, these macros work great. The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
Week 1
Week 2 etc. I am not sure why I'm having this issue, I have been able to do it on Excel 97, but for some reason it is not working in Excel 2007 "Ron de Bruin" wrote: Hi ZWatts773 See this example to save each sheet as a workbook http://www.rondebruin.nl/copy6.htm You can change the file name in this part of the code With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Name & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With What are the names of the week sheets ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Ron thanks for the info, these macros work great. The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
Where are the cells with the file names: 3-17
One name on each week tab ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Week 1 Week 2 etc. I am not sure why I'm having this issue, I have been able to do it on Excel 97, but for some reason it is not working in Excel 2007 "Ron de Bruin" wrote: Hi ZWatts773 See this example to save each sheet as a workbook http://www.rondebruin.nl/copy6.htm You can change the file name in this part of the code With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Name & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With What are the names of the week sheets ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Ron thanks for the info, these macros work great. The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
Cell G1 in each of the tabs
"Ron de Bruin" wrote: Where are the cells with the file names: 3-17 One name on each week tab ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Week 1 Week 2 etc. I am not sure why I'm having this issue, I have been able to do it on Excel 97, but for some reason it is not working in Excel 2007 "Ron de Bruin" wrote: Hi ZWatts773 See this example to save each sheet as a workbook http://www.rondebruin.nl/copy6.htm You can change the file name in this part of the code With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Name & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With What are the names of the week sheets ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Ron thanks for the info, these macros work great. The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
Then use this in this macro
http://www.rondebruin.nl/copy6.htm With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Cell G1 in each of the tabs "Ron de Bruin" wrote: Where are the cells with the file names: 3-17 One name on each week tab ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Week 1 Week 2 etc. I am not sure why I'm having this issue, I have been able to do it on Excel 97, but for some reason it is not working in Excel 2007 "Ron de Bruin" wrote: Hi ZWatts773 See this example to save each sheet as a workbook http://www.rondebruin.nl/copy6.htm You can change the file name in this part of the code With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Name & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With What are the names of the week sheets ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Ron thanks for the info, these macros work great. The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
Thanks for all your help Ron.
I got the Debug message. I tried replacing the With Destwb that you posted in this message in place of the With Destwb that is in the attached Macro. I also tried placing it in a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? Thoughts? I appreciate all your help, I am obviously in over my head. "Ron de Bruin" wrote: Then use this in this macro http://www.rondebruin.nl/copy6.htm With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Cell G1 in each of the tabs "Ron de Bruin" wrote: Where are the cells with the file names: 3-17 One name on each week tab ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Week 1 Week 2 etc. I am not sure why I'm having this issue, I have been able to do it on Excel 97, but for some reason it is not working in Excel 2007 "Ron de Bruin" wrote: Hi ZWatts773 See this example to save each sheet as a workbook http://www.rondebruin.nl/copy6.htm You can change the file name in this part of the code With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Name & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With What are the names of the week sheets ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Ron thanks for the info, these macros work great. The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
Try the exact macro from my site first
Is it working ? a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? No you copy each sheet to a new workbook so using the index 1 is always working because There is one sheet in each workbook. -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Thanks for all your help Ron. I got the Debug message. I tried replacing the With Destwb that you posted in this message in place of the With Destwb that is in the attached Macro. I also tried placing it in a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? Thoughts? I appreciate all your help, I am obviously in over my head. "Ron de Bruin" wrote: Then use this in this macro http://www.rondebruin.nl/copy6.htm With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Cell G1 in each of the tabs "Ron de Bruin" wrote: Where are the cells with the file names: 3-17 One name on each week tab ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Week 1 Week 2 etc. I am not sure why I'm having this issue, I have been able to do it on Excel 97, but for some reason it is not working in Excel 2007 "Ron de Bruin" wrote: Hi ZWatts773 See this example to save each sheet as a workbook http://www.rondebruin.nl/copy6.htm You can change the file name in this part of the code With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Name & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With What are the names of the week sheets ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Ron thanks for the info, these macros work great. The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
Yes, the macro works great otherwise, copies all the sheets to their own
workbook automatically named as the name that the sheet was in the first place "Ron de Bruin" wrote: Try the exact macro from my site first Is it working ? a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? No you copy each sheet to a new workbook so using the index 1 is always working because There is one sheet in each workbook. -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Thanks for all your help Ron. I got the Debug message. I tried replacing the With Destwb that you posted in this message in place of the With Destwb that is in the attached Macro. I also tried placing it in a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? Thoughts? I appreciate all your help, I am obviously in over my head. "Ron de Bruin" wrote: Then use this in this macro http://www.rondebruin.nl/copy6.htm With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Cell G1 in each of the tabs "Ron de Bruin" wrote: Where are the cells with the file names: 3-17 One name on each week tab ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Week 1 Week 2 etc. I am not sure why I'm having this issue, I have been able to do it on Excel 97, but for some reason it is not working in Excel 2007 "Ron de Bruin" wrote: Hi ZWatts773 See this example to save each sheet as a workbook http://www.rondebruin.nl/copy6.htm You can change the file name in this part of the code With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Name & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With What are the names of the week sheets ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Ron thanks for the info, these macros work great. The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#13
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
You say that in each sheet in G1 you have a file name
Correct ? Then this will work if you want to use that in the file name What happen if you use this ? With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Yes, the macro works great otherwise, copies all the sheets to their own workbook automatically named as the name that the sheet was in the first place "Ron de Bruin" wrote: Try the exact macro from my site first Is it working ? a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? No you copy each sheet to a new workbook so using the index 1 is always working because There is one sheet in each workbook. -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Thanks for all your help Ron. I got the Debug message. I tried replacing the With Destwb that you posted in this message in place of the With Destwb that is in the attached Macro. I also tried placing it in a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? Thoughts? I appreciate all your help, I am obviously in over my head. "Ron de Bruin" wrote: Then use this in this macro http://www.rondebruin.nl/copy6.htm With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Cell G1 in each of the tabs "Ron de Bruin" wrote: Where are the cells with the file names: 3-17 One name on each week tab ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Week 1 Week 2 etc. I am not sure why I'm having this issue, I have been able to do it on Excel 97, but for some reason it is not working in Excel 2007 "Ron de Bruin" wrote: Hi ZWatts773 See this example to save each sheet as a workbook http://www.rondebruin.nl/copy6.htm You can change the file name in this part of the code With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Name & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With What are the names of the week sheets ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Ron thanks for the info, these macros work great. The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#14
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
yes it is in G1
That code prompted the De-Bugger to open, I am not sure if I put it in the right place "Ron de Bruin" wrote: You say that in each sheet in G1 you have a file name Correct ? Then this will work if you want to use that in the file name What happen if you use this ? With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Yes, the macro works great otherwise, copies all the sheets to their own workbook automatically named as the name that the sheet was in the first place "Ron de Bruin" wrote: Try the exact macro from my site first Is it working ? a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? No you copy each sheet to a new workbook so using the index 1 is always working because There is one sheet in each workbook. -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Thanks for all your help Ron. I got the Debug message. I tried replacing the With Destwb that you posted in this message in place of the With Destwb that is in the attached Macro. I also tried placing it in a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? Thoughts? I appreciate all your help, I am obviously in over my head. "Ron de Bruin" wrote: Then use this in this macro http://www.rondebruin.nl/copy6.htm With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Cell G1 in each of the tabs "Ron de Bruin" wrote: Where are the cells with the file names: 3-17 One name on each week tab ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Week 1 Week 2 etc. I am not sure why I'm having this issue, I have been able to do it on Excel 97, but for some reason it is not working in Excel 2007 "Ron de Bruin" wrote: Hi ZWatts773 See this example to save each sheet as a workbook http://www.rondebruin.nl/copy6.htm You can change the file name in this part of the code With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Name & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With What are the names of the week sheets ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Ron thanks for the info, these macros work great. The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#15
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
This will work if every sheet have a value in G1
Maybe your problem is that not every sheet have a value in G1 Sub Copy_Every_Sheet_To_New_Workbook() 'Working in 97-2007 Dim FileExtStr As String Dim FileFormatNum As Long Dim Sourcewb As Workbook Dim Destwb As Workbook Dim sh As Worksheet Dim DateString As String Dim FolderName As String With Application .ScreenUpdating = False .EnableEvents = False .Calculation = xlCalculationManual End With 'Copy every sheet from the workbook with this macro Set Sourcewb = ThisWorkbook 'Create new folder to save the new files in DateString = Format(Now, "yyyy-mm-dd hh-mm-ss") FolderName = Sourcewb.Path & "\" & Sourcewb.Name & " " & DateString MkDir FolderName 'Copy every visible sheet to a new workbook For Each sh In Sourcewb.Worksheets 'If the sheet is visible then copy it to a new workbook If sh.Visible = -1 Then sh.Copy 'Set Destwb to the new workbook Set Destwb = ActiveWorkbook 'Determine the Excel version and file extension/format With Destwb If Val(Application.Version) < 12 Then 'You use Excel 97-2003 FileExtStr = ".xls": FileFormatNum = -4143 Else 'You use Excel 2007 If Sourcewb.Name = .Name Then MsgBox "Your answer is NO in the security dialog" GoTo GoToNextSheet Else Select Case Sourcewb.FileFormat Case 51: FileExtStr = ".xlsx": FileFormatNum = 51 Case 52: If .HasVBProject Then FileExtStr = ".xlsm": FileFormatNum = 52 Else FileExtStr = ".xlsx": FileFormatNum = 51 End If Case 56: FileExtStr = ".xls": FileFormatNum = 56 Case Else: FileExtStr = ".xlsb": FileFormatNum = 50 End Select End If End If End With 'Change all cells in the worksheet to values if you want If Destwb.Sheets(1).ProtectContents = False Then With Destwb.Sheets(1).UsedRange .Cells.Copy .Cells.PasteSpecial xlPasteValues .Cells(1).Select End With Application.CutCopyMode = False End If 'Save the new workbook and close it With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With End If GoToNextSheet: Next sh MsgBox "You can find the files in " & FolderName With Application .ScreenUpdating = True .EnableEvents = True .Calculation = xlCalculationAutomatic End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... yes it is in G1 That code prompted the De-Bugger to open, I am not sure if I put it in the right place "Ron de Bruin" wrote: You say that in each sheet in G1 you have a file name Correct ? Then this will work if you want to use that in the file name What happen if you use this ? With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Yes, the macro works great otherwise, copies all the sheets to their own workbook automatically named as the name that the sheet was in the first place "Ron de Bruin" wrote: Try the exact macro from my site first Is it working ? a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? No you copy each sheet to a new workbook so using the index 1 is always working because There is one sheet in each workbook. -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Thanks for all your help Ron. I got the Debug message. I tried replacing the With Destwb that you posted in this message in place of the With Destwb that is in the attached Macro. I also tried placing it in a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? Thoughts? I appreciate all your help, I am obviously in over my head. "Ron de Bruin" wrote: Then use this in this macro http://www.rondebruin.nl/copy6.htm With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Cell G1 in each of the tabs "Ron de Bruin" wrote: Where are the cells with the file names: 3-17 One name on each week tab ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Week 1 Week 2 etc. I am not sure why I'm having this issue, I have been able to do it on Excel 97, but for some reason it is not working in Excel 2007 "Ron de Bruin" wrote: Hi ZWatts773 See this example to save each sheet as a workbook http://www.rondebruin.nl/copy6.htm You can change the file name in this part of the code With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Name & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With What are the names of the week sheets ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Ron thanks for the info, these macros work great. The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
#16
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetSaveAs Issue in Excel 97
GREAT! THANK YOU!
It worked that time, not sure what the issue was "Ron de Bruin" wrote: This will work if every sheet have a value in G1 Maybe your problem is that not every sheet have a value in G1 Sub Copy_Every_Sheet_To_New_Workbook() 'Working in 97-2007 Dim FileExtStr As String Dim FileFormatNum As Long Dim Sourcewb As Workbook Dim Destwb As Workbook Dim sh As Worksheet Dim DateString As String Dim FolderName As String With Application .ScreenUpdating = False .EnableEvents = False .Calculation = xlCalculationManual End With 'Copy every sheet from the workbook with this macro Set Sourcewb = ThisWorkbook 'Create new folder to save the new files in DateString = Format(Now, "yyyy-mm-dd hh-mm-ss") FolderName = Sourcewb.Path & "\" & Sourcewb.Name & " " & DateString MkDir FolderName 'Copy every visible sheet to a new workbook For Each sh In Sourcewb.Worksheets 'If the sheet is visible then copy it to a new workbook If sh.Visible = -1 Then sh.Copy 'Set Destwb to the new workbook Set Destwb = ActiveWorkbook 'Determine the Excel version and file extension/format With Destwb If Val(Application.Version) < 12 Then 'You use Excel 97-2003 FileExtStr = ".xls": FileFormatNum = -4143 Else 'You use Excel 2007 If Sourcewb.Name = .Name Then MsgBox "Your answer is NO in the security dialog" GoTo GoToNextSheet Else Select Case Sourcewb.FileFormat Case 51: FileExtStr = ".xlsx": FileFormatNum = 51 Case 52: If .HasVBProject Then FileExtStr = ".xlsm": FileFormatNum = 52 Else FileExtStr = ".xlsx": FileFormatNum = 51 End If Case 56: FileExtStr = ".xls": FileFormatNum = 56 Case Else: FileExtStr = ".xlsb": FileFormatNum = 50 End Select End If End If End With 'Change all cells in the worksheet to values if you want If Destwb.Sheets(1).ProtectContents = False Then With Destwb.Sheets(1).UsedRange .Cells.Copy .Cells.PasteSpecial xlPasteValues .Cells(1).Select End With Application.CutCopyMode = False End If 'Save the new workbook and close it With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With End If GoToNextSheet: Next sh MsgBox "You can find the files in " & FolderName With Application .ScreenUpdating = True .EnableEvents = True .Calculation = xlCalculationAutomatic End With End Sub -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... yes it is in G1 That code prompted the De-Bugger to open, I am not sure if I put it in the right place "Ron de Bruin" wrote: You say that in each sheet in G1 you have a file name Correct ? Then this will work if you want to use that in the file name What happen if you use this ? With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Yes, the macro works great otherwise, copies all the sheets to their own workbook automatically named as the name that the sheet was in the first place "Ron de Bruin" wrote: Try the exact macro from my site first Is it working ? a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? No you copy each sheet to a new workbook so using the index 1 is always working because There is one sheet in each workbook. -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Thanks for all your help Ron. I got the Debug message. I tried replacing the With Destwb that you posted in this message in place of the With Destwb that is in the attached Macro. I also tried placing it in a different area. My question I guss is if I should change the part that says Sheets(1) to the actual name of the sheets? Thoughts? I appreciate all your help, I am obviously in over my head. "Ron de Bruin" wrote: Then use this in this macro http://www.rondebruin.nl/copy6.htm With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Range("G1").Value & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Cell G1 in each of the tabs "Ron de Bruin" wrote: Where are the cells with the file names: 3-17 One name on each week tab ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Week 1 Week 2 etc. I am not sure why I'm having this issue, I have been able to do it on Excel 97, but for some reason it is not working in Excel 2007 "Ron de Bruin" wrote: Hi ZWatts773 See this example to save each sheet as a workbook http://www.rondebruin.nl/copy6.htm You can change the file name in this part of the code With Destwb .SaveAs FolderName _ & "\" & Destwb.Sheets(1).Name & FileExtStr, _ FileFormat:=FileFormatNum .Close False End With What are the names of the week sheets ? -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... Ron thanks for the info, these macros work great. The only thing I need to do is have it reference a Cell in the workbook for the filename. This is a workbook that has fiscal months and a tab for each week. The weekly needs to be separated out and saved in a specific format ie ZWatts 3-17 to 3-23. I have a cell programmed with the appropriate filename format but am unable to get it to reference. Thoughts? Is this possible? "Ron de Bruin" wrote: Hi ZWatts773 Read the info on this page http://www.rondebruin.nl/saveas.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ZWatts773" wrote in message ... I am trying to export 1 sheet to a new workbook with a specific save as filename. The filename is created by the excel worksheet in a specific cell. The issue I have now is getting Excel to save the file as an excel workbook. The following code works except it does not specify file type: Dim vSaveWeekly As String vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1")) If vSaveWeekly = "False" Then Exit Sub End If Application.ThisWorkbook.SaveAs vSaveWeekly When I add in the file filter I get: "Compile Error: Expected List Separator or )" I programmed it as this: vSaveWeekly = Application.GetSaveAsFilename(Worksheets("Week 1").Range("G1"),"Excel Workbooks *.xlsm)" ,*.xlsm) Please help, I just need the program to save the file with the specified name which will always be in the referenced cell, and it needs to be saved as an Excel 2007 file. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
New to VBA..need help with automating GETSAVEAS Macro in Excel 2003 | Excel Programming | |||
timeout on GetSaveAs? | Excel Programming | |||
No Success with GetSaveAs | Excel Discussion (Misc queries) | |||
GetSaveAs Method | Excel Programming | |||
Using GetSaveAs | Excel Programming |