I can't get the IDEA script to open a Excel file, i also can't find the answer on Google. Is there anyone with some experience with this?
Sub Main
Dim Workbooks As Object
Dim ActiveWorkbook As Object
Dim File As String
File = "H:\!OHW\IDEA\Test Project 01 (9999990)\Import Definitions.ILB\Import definitions.xlsx"
Set Workbooks = CreateObject("Excel.Sheet")
Workbooks.Application.Visible = True
Workbooks.Open (File)
'Workbooks.Application.Quit
'Set Workbooks = Nothing
MsgBox "Gereed"
End Sub
Robert van den ...
Offline
Last seen: 3 years 4 days ago
Joined: 08/08/2018 - 07:37
Hi Robert,
maybe the following post will help you: http://ideascripting.com/wiki/how-read-excel-worksheets-through-ideascript
Otherwise I can confirm that code works:
Sub Main
Dim oApp As Object
Dim oBook As Object
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
Set oBook = oApp.Workbooks.Open("H:\!OHW\IDEA\Test Project 01 (9999990)\Import Definitions.ILB\Import definitions.xlsx")
Set oApp = Nothing
Set oBook = Nothing
End Sub
Regards klmi
thanks for your reaction, i created a script to read the content of a Excel file into an array (see the attached file). Is it possible to make a database file (IMD file) from that array?
Yes it is but it is not the easiest thing to do. In the language browser check out Client.NewDatabase for the code. I usually do this in two parts, I create the database with the fields in it and then I add the information in the fields, usually through two functions. Also after you have added the rows to your database you need to close and open your database for the information to appear, if you don't do this you will think nothing has happened, took me awhile to figure that one out.
Brian
Hi, I got a script working where the data from the Excel is put into an array and then into a new database (took me this entire day to get it right, see the attached file for the script). The only problem I have now is that the new database is editable where I can edit and delete the values even when the NewTable.Protect is set to True. The AddedField.Type is set to WI_CHAR_FIELD, I tried VIRT_CHAR but then IDEA crashes directly. Any suggestions? I don't really like the idea that someone can change the values in the database/IMD file.
I always have to break it down into two functions to get it to work properly. I have attached an example using your scenario.
What happens is it turns the field into an edit field and if you check in the history the changes are noted.