Hi All,
I am able to open but not save and close another workbook from the current workbook using macro.
This is the code that i am using.
Please help me to modify the code.Please Login or Register to view this content.
Regards
Kumar
Hi All,
I am able to open but not save and close another workbook from the current workbook using macro.
This is the code that i am using.
Please help me to modify the code.Please Login or Register to view this content.
Regards
Kumar
Dear Ravi,
Create a Worksheet variable
assign the workbook to this variable
replace the path in below code it will work.
Sub hhgg()
Dim x As Workbook
Set x = Application.Workbooks.Open("C:\Documents and Settings\Md.aejaz\Desktop\WORKING Sync Repot MOC6")
Application.Workbooks(x.Name).Close
End Sub
please rate if u are satisfied with this post by selecting the star from below.
I think its just that you don't need the filepath in your save and close instructions:
Good luck!Please Login or Register to view this content.
If I helped you today please rate me
Sorry guys,
A mistake is happened from my side i have posted my question wrongly.
When i am opening another workbook,I need to save and close the existed workbook.
This is how i want.
Please help me in this.
Regards
Kumar
Please Login or Register to view this content.
Hi Imvk99,
If i save and close the file in the begin itself ,How the next code lines will work in the macro.
Hope you understand the problem.
This is how my code will look like
RegardsPlease Login or Register to view this content.
Kumar
Apologies, I edited it wrong. Your code is really close. If you know the names of "First" and "Second" then you can just hardcode in the names and put the macro in a module in "first". But if you want this to run without it closing when "first" closes, just make a master file that stays open while doing all of this and save it to a module in there. If you want this to run over and over again for "third" and "fourth" etc, let me know and we can work on that.
Please Login or Register to view this content.
Thanks for the reply.
Any how i got the solution.
Actually with this code i am able open second file and closing the "first" file.Please Login or Register to view this content.
Now again from the "Second" file, I can open the "first" file and close the "Second" file(Because i know that is first file ,I am hard coding).
Here i have a problem.
I can open "the" second file from any of the "first" file(Eg: First,First1,First2,First3.....etc)
In my "first" files,I am not using it's name any where.But my target is to get "second" file.So i can achieve this thing with any of the file by hard coding the "second" file name.
For to avoid the hard coding the "first" files
how to identify the previous file from which file the "second" file is open and from here i want to redirect to the previous "first" file.
Please see the attached image.
Dynamical.PNG
Regards
Kumar
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks