Hi All,
I'm still struggling along with my Quote spreadsheet. Very much a newbie to VBA, but trying....
My spreadsheet pulls last row data from a register to fill fields for a new quote (Date, Company, Quote#) it's a bit of a hack using LOOKUP, =LOOKUP(2,1/('[Quote Register.xlsm]Register'!$B:$B<>""),('[Quote Register.xlsm]Register'!$B:$B)) etc. for the three fields.
I have some code that should break the links when saved as a new workbook.The problem is that the saved workbook still contains all of the links that were in the original file. Does anyone know a way that I can save the file as values only without the links? If a previously saved workbook is opened for changes to the quote, the fields get updated with newer register data.
My Code: Has a few snippets which are not necessary? eg: Dim fname As String and fname = ActiveWorkbook.Name
I've been trying to edit existing code on the run and these were part of an old iteration. I did say I was a learner, my day job is flying airplanes ..
Sub SaveQuote()
Dim fname As String
Dim newFile As String
Dim NewBook As Workbook
fname = ActiveWorkbook.Name
ChDir "C:\users\paul\documents\"
Call break_links(NewBook)
ActiveWorkbook.SaveAs Filename:="C:\Users\Paul\Documents\Quote" & " " & Range("D11").Value & " " & Range("K9").Value & (".xlsm")
End Sub
Sub break_links(ByRef wb As Workbook)
Dim Links As Variant
On Error Resume Next
Links = wb.LinkSources(Type:=xlLinkTypeExcelLinks)
On Error GoTo 0
If Not IsEmpty(Links) Then
For I = 1 To UBound(Links)
wb.BreakLink _
Name:=Links(I), _
Type:=xlLinkTypeExcelLinks
Next I
End If
End Sub
Best regards...
Bookmarks