mmaksimovik
New Member
- Joined
- Sep 26, 2017
- Messages
- 1
Hello guys,
I am new to this forum. Thanks to everyone who is making a contribution, and sharing their knowledge.
I have a whole network of Excel files linked between themselves. At the beginning of every month, I am making copies of each file, reflecting the month and year in the name of each file.
In order not to link them one by one every month, I made a Macro following a simple logic. The Macro seems to work for most of the files, however, in one file, I encountered a problem.
Here is my code:
Dim MISWB As Workbook
Workbooks.Open Filename:="Y:\AM\20" & Godina & "\MIS_" & Godina & "\1MIS" & Godina & Mesec & ".xlsx", UpdateLinks:=0
Set MISWB = ActiveWorkbook
'*****INPUT*****
ChDir "Y:\AM\20" & Godina & "\INPUT_" & Godina
ActiveWorkbook.ChangeLink Name:="Y:\AM\20" & Godina & "\INPUT_" & Godina & "\INPUT" & Godina & PrethodenMesec & ".xlsx", NewName:= _
"INPUT" & Godina & Mesec & ".xlsx", Type:=xlExcelLinks
Where:
- Godina = year
- Mesec = current month
- Prethoden mesec = previous month
Well, when I have the file INPUT1709.xlsx open in the background, the Macro seems to be updating the link correctly.
When I don't have it open, and run the Macro, it doesn't change the link correctly, as if "INPUT1709.xlsx" doesn't exist. That's what it says when I click "OPEN SOURCE" from the "EDIT LINKS" tab.
In other files, the same code works without a problem, no matter if the INPUT file is open or not. For example:
'|***********************KWH***********************|
Dim KWHWB As Workbook
Workbooks.Open Filename:="Y:\AM\20" & Godina & "\KWH_" & Godina & "\KWh_" & Godina & Mesec & ".xls", UpdateLinks:=0
Set KWHWB = ActiveWorkbook
'*****INPUT*****
ChDir "Y:\AM\20" & Godina & "\INPUT_" & Godina
ActiveWorkbook.ChangeLink Name:="Y:\AM\20" & Godina & "\INPUT_" & Godina & "\INPUT" & Godina & PrethodenMesec & ".xlsx", NewName:= _
"INPUT" & Godina & Mesec & ".xlsx", Type:=xlExcelLinks
Any ideas what is going on here?
Thank you.
I am new to this forum. Thanks to everyone who is making a contribution, and sharing their knowledge.
I have a whole network of Excel files linked between themselves. At the beginning of every month, I am making copies of each file, reflecting the month and year in the name of each file.
In order not to link them one by one every month, I made a Macro following a simple logic. The Macro seems to work for most of the files, however, in one file, I encountered a problem.
Here is my code:
Dim MISWB As Workbook
Workbooks.Open Filename:="Y:\AM\20" & Godina & "\MIS_" & Godina & "\1MIS" & Godina & Mesec & ".xlsx", UpdateLinks:=0
Set MISWB = ActiveWorkbook
'*****INPUT*****
ChDir "Y:\AM\20" & Godina & "\INPUT_" & Godina
ActiveWorkbook.ChangeLink Name:="Y:\AM\20" & Godina & "\INPUT_" & Godina & "\INPUT" & Godina & PrethodenMesec & ".xlsx", NewName:= _
"INPUT" & Godina & Mesec & ".xlsx", Type:=xlExcelLinks
Where:
- Godina = year
- Mesec = current month
- Prethoden mesec = previous month
Well, when I have the file INPUT1709.xlsx open in the background, the Macro seems to be updating the link correctly.
When I don't have it open, and run the Macro, it doesn't change the link correctly, as if "INPUT1709.xlsx" doesn't exist. That's what it says when I click "OPEN SOURCE" from the "EDIT LINKS" tab.
In other files, the same code works without a problem, no matter if the INPUT file is open or not. For example:
'|***********************KWH***********************|
Dim KWHWB As Workbook
Workbooks.Open Filename:="Y:\AM\20" & Godina & "\KWH_" & Godina & "\KWh_" & Godina & Mesec & ".xls", UpdateLinks:=0
Set KWHWB = ActiveWorkbook
'*****INPUT*****
ChDir "Y:\AM\20" & Godina & "\INPUT_" & Godina
ActiveWorkbook.ChangeLink Name:="Y:\AM\20" & Godina & "\INPUT_" & Godina & "\INPUT" & Godina & PrethodenMesec & ".xlsx", NewName:= _
"INPUT" & Godina & Mesec & ".xlsx", Type:=xlExcelLinks
Any ideas what is going on here?
Thank you.