View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ewan7279 ewan7279 is offline
external usenet poster
 
Posts: 97
Default Help to Break links please!!

Hi All,

My code copies a summary sheet from one workbook into another, and the
copied sheet contains links that I want to get rid of and formulae that I
want to keep. I have tried various ways to get rid of the links, but have
been unsuccessful so far. I get a runtime error 1004 message 'Method
'BreakLink' of object '_Workbook' failed' at the highlighted line of code
with my latest attempt:

Private Sub UpdateQuarters_Click()

'On Error GoTo ErrorHandler
ActiveSheet.Unprotect

Dim linkpath, homefile, masterquarterfile, quartermonth, sumsheet As Variant

linkpath = Application.ActiveWorkbook.FullName
homefile = ActiveWorkbook.Name
sumsheet = ActiveSheet.Name

MsgBox "Please select the Quarterly Template file you wish to open",
vbOKOnly, "Select File"
masterquarterfile = Application.GetOpenFilename()
A = MsgBox("Open " & masterquarterfile & "?", vbYesNoCancel, "Open Quarterly
Template file")
If A = vbNo Then
'GoTo ErrorHandler
Exit Sub
Else
If A = vbCancel Then
'GoTo ErrorHandler
Exit Sub
End If
End If
Workbooks.OpenText masterquarterfile
masterquarterfile = ActiveWorkbook.Name

Windows(homefile).Activate
Sheets(sumsheet).Select
ActiveSheet.Unprotect
linkpath = Application.ActiveWorkbook.FullName
Sheets(sumsheet).Copy After:=Workbooks(masterquarterfile).Sheets("front" )
ActiveSheet.Shapes("UpdateSummary").Select
Selection.Delete
ActiveSheet.Shapes("UpdateQuarters").Select
Selection.Delete

MsgBox linkpath

ActiveWorkbook.BreakLink Name:=linkpath, Type:=xlLinkTypeExcelLinks <=ERROR
LINE

etc etc