HopefulGJL
Board Regular
- Joined
- Nov 28, 2008
- Messages
- 100
Hello. The below code is creating a new workbook for me (.xlsx with no code) based on the name in cell A2 of Sheet1 (which changes based on the name in cell A1 of Sheet1). It also closes the new workbook, and keeps this .xslm workbook open exactly as I need it to do.
It next deletes all the external links in the new workbook to keep just the values, which is also what I need it to do.
However, it's prompting to confirm saving as .xlsx each time. I'm looking for it to just do that without asking. I'm purely guessing it might need a SaveChanges:=False somewhere, but I don't know where to put it. I've tried different places, and haven't been successful.
Thanks in advance for any information you can provide.
It next deletes all the external links in the new workbook to keep just the values, which is also what I need it to do.
However, it's prompting to confirm saving as .xlsx each time. I'm looking for it to just do that without asking. I'm purely guessing it might need a SaveChanges:=False somewhere, but I don't know where to put it. I've tried different places, and haven't been successful.
Thanks in advance for any information you can provide.
VBA Code:
Sub BreakLinksandSave()
Dim link As Variant, wb As Workbook, origFile As String, newFile As String
Set wb = Application.ActiveWorkbook
If Not IsEmpty(wb.LinkSources(xlExcelLinks)) Then
For Each link In wb.LinkSources(xlExcelLinks)
wb.BreakLink link, xlLinkTypeExcelLinks
Next link
End If
origFile = wb.FullName
newFile = ActiveWorkbook.Sheets(1).Range("A2").Value
ActiveWorkbook.SaveAs Filename:="C:\File Pathway\" & newFile, FileFormat:=xlOpenXMLWorkbook
newFile = ActiveWorkbook.Name
Application.DisplayAlerts = False
Workbooks.Open origFile, UpdateLinks:=True
Application.DisplayAlerts = True
Workbooks(newFile).Close False
End Sub