Leisuregroove
New Member
- Joined
- Jan 25, 2019
- Messages
- 5
Hello,
I wonder if anyone can help me. I am a complete novice at VBA so please excuse me.
I have some code, which opens another work book, "saves as" in a different folder then deletes the file.
This is done to keep the links on a linked document when moving the linked documents.
I want to know how do I automatically save the last document which is opened instead of getting a prompt to save changes made.
here's my code.
' Macro1 Macro
'
Sub Open_Acc1_CANCEL()
'
Workbooks.Open Filename:= _
"W:\Accumulative\Accumulative 2018-2019\SSC8 - Health & Fitness.xlsm", _
UpdateLinks:=0
ActiveWorkbook.Save
Windows("HAF959 - Mental Health"). _
Activate
For Each w In Application.Workbooks
w.Save
Next w
Application.Quit
Dim strWbKill As String
With ThisWorkbook
strWbKill = .FullName
.SaveAs "W:\Cancelled courses\HAF959 - Mental Health.xlsm"
End With
KILL strWbKill
ActiveWorkbook.Close
End Sub
When all this code is run, there is one last document which Is W:\Accumulative\Accumulative 2018-2019\SSC8 - Health & Fitness.xlsm . I am prompted to save but I need the code to save automatically.
pulling my hair out lol....
Best,
LG
I wonder if anyone can help me. I am a complete novice at VBA so please excuse me.
I have some code, which opens another work book, "saves as" in a different folder then deletes the file.
This is done to keep the links on a linked document when moving the linked documents.
I want to know how do I automatically save the last document which is opened instead of getting a prompt to save changes made.
here's my code.
' Macro1 Macro
'
Sub Open_Acc1_CANCEL()
'
Workbooks.Open Filename:= _
"W:\Accumulative\Accumulative 2018-2019\SSC8 - Health & Fitness.xlsm", _
UpdateLinks:=0
ActiveWorkbook.Save
Windows("HAF959 - Mental Health"). _
Activate
For Each w In Application.Workbooks
w.Save
Next w
Application.Quit
Dim strWbKill As String
With ThisWorkbook
strWbKill = .FullName
.SaveAs "W:\Cancelled courses\HAF959 - Mental Health.xlsm"
End With
KILL strWbKill
ActiveWorkbook.Close
End Sub
When all this code is run, there is one last document which Is W:\Accumulative\Accumulative 2018-2019\SSC8 - Health & Fitness.xlsm . I am prompted to save but I need the code to save automatically.
pulling my hair out lol....
Best,
LG