Hi Everyone,
I'm Massimiliano and I'm writing you from Italy, so sorry for my English, I'm not so good
For my job I have to manage a lot of Excel files and I'm creating a macro to help me do my work faster about opening and savings
Here below You can find the code I wrote, I know it is a bit rudimental but I'm just starting out
I have to open File A and File B which are linked to a Pivot in File 1. I open both file. Than I save with name File A and file B in a new directory
At this point I would break all the links in File A and in File B. I tried to do this but it doesn't work (See below "ActiveWorkbook.BreakLink Name:="Percorso file\File 1.xlsx", Type:=xlExcelLinks")
Could you please help me? I found different solutions in the web but I've the feeling that those would break links in all opened files including File 1 (which doesn't have to be changed)
The real point is that during the Macro, File 1 - in my opinion - must be open, and action of "breaklinks" have to be implemented just in File A and File B
Thank you so much
Massimiliano
I'm Massimiliano and I'm writing you from Italy, so sorry for my English, I'm not so good
For my job I have to manage a lot of Excel files and I'm creating a macro to help me do my work faster about opening and savings
Here below You can find the code I wrote, I know it is a bit rudimental but I'm just starting out
I have to open File A and File B which are linked to a Pivot in File 1. I open both file. Than I save with name File A and file B in a new directory
At this point I would break all the links in File A and in File B. I tried to do this but it doesn't work (See below "ActiveWorkbook.BreakLink Name:="Percorso file\File 1.xlsx", Type:=xlExcelLinks")
Could you please help me? I found different solutions in the web but I've the feeling that those would break links in all opened files including File 1 (which doesn't have to be changed)
The real point is that during the Macro, File 1 - in my opinion - must be open, and action of "breaklinks" have to be implemented just in File A and File B
Thank you so much
Massimiliano
Code:
Sub OPEN FILE A, FILE B AND FILE 1. SAVE WITH NAME FILE A AND FILE B IN A NEW DIRECTORY. BREAK LINKS IN FILE A AND FILE B
' OPEN FILE 1
'Application.Workbooks.Open Filename:="Percorso file 1\File 1.xlsx", UpdateLinks:=False
' OPEN FILE A
Application.Workbooks.Open Filename:="Percorso file A\File A.xlsx", UpdateLinks:=False
' OPEN FILE B
Application.Workbooks.Open Filename:="Percorso file B\File B.xlsx", UpdateLinks:=False
' SAVE WITH NAME FILE A AND FILE B OVERWRITING IN THE NEW DIRECTORY + ATTEMPT TO BREAK LINKS
‘ SAVE WITH NAME FILE A
Workbooks("File A.xlsx").SaveCopyAs Filename:="Nuovo percorso file A\File A.xlsx"
‘ OVERWRITE FILE A IN THE NEW DIRECTORY
Application.DisplayAlerts = True
‘ BREAK LINKS IN FILE A
ActiveWorkbook.BreakLink Name:="Percorso file\File 1.xlsx", Type:=xlExcelLinks
‘ SAVE WITH NAME FILE B
Workbooks("File B.xlsx").SaveCopyAs Filename:="Nuovo percorso file B\File B.xlsx"
‘ OVERWRITE FILE A IN THE NEW DIRECTORY
Application.DisplayAlerts = True
‘ BREAK LINKS IN FILE A
ActiveWorkbook.BreakLink Name:="Percorso file\File 1.xlsx", Type:=xlExcelLinks
End Sub