Erase a cell that has a link before the file is saved

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
I have code below.

Code:
Select Case WB1.Sheets("FRONT").Range("C2").Value
        Case "MD"
            strfilename = "\\MIKESRGATEWAY\MikesProposals\" & strfilename
            
        Case "TD"
            strfilename = "\\Tomsblackibm\TomsProposals\" & strfilename
            
        Case "DJ"
            strfilename = "\\DAVEJONES\DavesProposals\" & strfilename
            
        Case "CP"
            strfilename = "\\Chuckscomputer\daily\" & strfilename
            
    End Select
    
    WB1.SaveCopyAs Filename:=strfilename
    
    WB1.ActiveSheet.Shapes("Button 53").Visible = False
    
    ChDir CurrPath
    
    Application.ScreenUpdating = True
    
    WB1.Close

Where can I enter...
Range("M3").ClearContents
So when saved to the new computer this link is gone?

Thank You,
Michael
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Code:
Option Explicit 
 
Sub DeleteLinksInBook() 
    Dim Ws As Worksheet, FirstSheet As Worksheet 
    Dim Query As VbMsgBoxResult 
    Query = MsgBox("CAUTION: Every single link, formula " & _ 
    "& hyperlink in this " & vbLf & _ 
    "book will be deleted - Do you " & _ 
    "still want to proceed?", vbYesNo, _ 
    "Sever All Links?") 
    If Query = vbNo Then Exit Sub 
    Set FirstSheet = ActiveSheet 
    Application.ScreenUpdating = False 
    For Each Ws In Worksheets 
        Ws.Activate 
         
         '****remove formulae & external links****
        With Cells 
            .Select 
            .Copy 
            Selection.PasteSpecial Paste:=xlValues 
            Application.CutCopyMode = False 
        End With 
         '**********************************
         
         '*********Remove Hyperlinks**********
        Cells.Hyperlinks.Delete 
         '**********************************
         
        [A1].Select 
    Next 
    FirstSheet.Activate 
End Sub

Found this code on vbaexpress knowledge base. You should be able to adopt this to your use.
 
Upvote 0
Thank You for your help!
I know the cell to erase that has the link.
I just need to know where to enter it in my code I provided!!

Michael
 
Upvote 0
mabye on the BeforeSave event

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
sheets("sheetname").Range("M3").ClearContents 
End Sub

since this is in a Workbook event, not a sheet event I believe you will have to specify the sheetname as well as the range.
 
Upvote 0

Forum statistics

Threads
1,223,604
Messages
6,173,315
Members
452,510
Latest member
RCan29

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top