Quote:
Originally Posted by PRA007
Actually I wanted to automate few things using vbscript.
...
This code further runs macro solution given by you above.
|
You hadn't previously mentioned wanting to automate in this way. Even so, that code won't run the macro I posted, since it tries to use a workbook named 'Fees.xlsm' and your attachment workbooks were named 'Main.xlsx' and 'Database2.xlsx'.
Furthermore, in post #7 you have:
Code:
Set wkb = Workbooks.Open("C:\Users\rahulkumar.patel\Desktop\Sheet1.xlsx")
Set wkb1 = Workbooks.Open("C:\Users\rahulkumar.patel\Desktop\FE.xlsx")
Set xlShtTgt = Workbooks("Sheet1.xlsx").Sheets(1)
Set xlShtSrc = Workbooks("FE.xlsx").Sheets(1)
Aside from the fact that could could be reduced to:
Code:
Set wkb = Workbooks.Open("C:\Users\rahulkumar.patel\Desktop\Sheet1.xlsx")
Set wkb1 = Workbooks.Open("C:\Users\rahulkumar.patel\Desktop\FE.xlsx")
Set xlShtTgt = wkb .Sheets(1)
Set xlShtSrc = wkb 1.Sheets(1)
this code doesn't do any of the checking to see if either workbook is already open. As I said in post #8, I've already given you code showing how to do that. If you don't do such checks, you risk having your macro crash.