Hi,
I'm very new to VBA and trying to experiment with new macros. I have recorded a macro and saved into my Personal.xlsb workbook because I would like to use on many worksheets in the future. This code below is to save all my worksheets in the workbook as new files. It works when I have the exact module in a separate workbook however when I try to run the macro for another workbook through Personal.xlsb, I get an out of stack space error. Any help you guys have would be much appreciated. Thank you
Sub SaveSheets()
'
' SaveSheets Macro
'
' Keyboard Shortcut: Ctrl+Shift+S
'
Application.Run "PERSONAL.XLSB!SaveSheets"
Dim strPath As String
Dim ws As Worksheet
Application.ScreenUpdating = False
strPath = ActiveWorkbook.Path & "\"
For Each ws In ThisWorkbook.Sheets
ws.Copy
'Use this line if you want to break any links:
BreakLinks Workbooks(Workbooks.Count)
Workbooks(Workbooks.Count).Close True, strPath & ws.Name & ".xlsx"
Next
Application.ScreenUpdating = True
End Sub
Sub BreakLinks(wb As Workbook)
Dim lnk As Variant
For Each lnk In wb.LinkSources(xlExcelLinks)
wb.BreakLink lnk, xlLinkTypeExcelLinks
Next
End Sub
I'm very new to VBA and trying to experiment with new macros. I have recorded a macro and saved into my Personal.xlsb workbook because I would like to use on many worksheets in the future. This code below is to save all my worksheets in the workbook as new files. It works when I have the exact module in a separate workbook however when I try to run the macro for another workbook through Personal.xlsb, I get an out of stack space error. Any help you guys have would be much appreciated. Thank you
Sub SaveSheets()
'
' SaveSheets Macro
'
' Keyboard Shortcut: Ctrl+Shift+S
'
Application.Run "PERSONAL.XLSB!SaveSheets"
Dim strPath As String
Dim ws As Worksheet
Application.ScreenUpdating = False
strPath = ActiveWorkbook.Path & "\"
For Each ws In ThisWorkbook.Sheets
ws.Copy
'Use this line if you want to break any links:
BreakLinks Workbooks(Workbooks.Count)
Workbooks(Workbooks.Count).Close True, strPath & ws.Name & ".xlsx"
Next
Application.ScreenUpdating = True
End Sub
Sub BreakLinks(wb As Workbook)
Dim lnk As Variant
For Each lnk In wb.LinkSources(xlExcelLinks)
wb.BreakLink lnk, xlLinkTypeExcelLinks
Next
End Sub