Daniel Pech
Offline
Last seen: 8 months 1 week ago
Joined: 11/06/2014 - 05:03
Dear Brian
Thank you very much for your response. I appreciate your help. I have a challenge understanding the code you wrote. I am new to IDEA.
Hi Baricha,
Well the script I would consider for advanced users as it has you creating code to manipulate Excel. I will try and explain what the script does. In the Sub Main you are setting up your list of IDEA files that you want exported and then merged into one Excel file. You then call the createExcelSheet function.
It first creates an array sExcelName() to hold the names of the Excel file names. The array is made the same size as the sExcelExportList by using the ubound function (this gets the number of items in an array or the upper boundary of an array).
For For Next loop takes the name of the IDEA filed, strips off the IMD and adds the XLSX file extension. It then calls the IDEA task to export the file to the Exports.ILB directory under the project folder.
At this point you have all your files as separate Excel files.
The next block of code creates an Excel object and creates a new Excel file in the Exports.ILB folder that will hold all your separate Excel files.
The next block then uses a for next loop that opens each individual Excel spreadsheet, copies the information from the worksheet and then pastes it into a new worksheet in your new Excel spreadsheet. The code then does an autofit so that the column widths show all the information.
It then closes each of the Excel spreadsheets, once everything has been copied over it saves the new worksheet, closes it and exists Excel.
Hopefully that makes a bit more sense.
Thanks
Brian
Dear Brian
I replaced the values in the script and got error 39 (Invalid Database).
Set db = Client.OpenDatabase(sExcelExportList(i))
Please see attached.
Change the:
ReDim sExcelExportList(5)
to
ReDim sExcelExportList(3)
If you don't it will be looking for 6 databases instead of your 4.
Dear Brian
Thank very much, the explanation makes sense.
Dear Brain
It has partly worked, It exported the 4 files to my IDEA exports but failed creating a new excel workbook for combining the 4 files.
Kindly note i had done this
Set fso = CreateObject("Scripting.FileSystemObject")
workDir = Client.WorkingDirectory
Path = workDir
Kindly see attached.
Hi Barachi,
Thanks for also posting the code. From your code this is mostly like the problem. You placed:
Const EXCEL_FILENAME = "Bulk_Results.XLSX" 'name of new excel file
In the sub main, you need this as a global variable so remove it from the sub main and place it above the sub main, in the area where you declare your Global variables.
That should hopefully fix your error.
Brian
Dear Brian
Apologies for the late response. I want to thank you immensely for your assistance. The code has worked perfectly!. Thank you very much.
My pleasure, glad you have it working.
Brian
Dear Brian
One last question. How do I add "check file exist" on exportation script. I tried as attached and it did not work
Pages