Hello everyone,
Hope you all are doing great.
I have a question regarding data importing. Is it possible to append a column with its file name when it is importing to IDEA? for example, My file name is XXX and i want to import the file into IDEA and after that i need to append the file name (i.e. XXX) to that database as a seperate column. I use to utilize multiple data import macro which i sdeveloped by Brian and that is really amazing. Is it possible to incoporate this option to that?
Eagerly waiting for valuable suggestions
Thanks,
Bibin K B
bbaburaj
Offline
Last seen: 7 years 2 months ago
Joined: 10/26/2016 - 05:56
Hi Bibin,
Yes it is. If you look at my script for importing multiple files I have that option included in there so feel free to steal the code. If you need some help integrating it with your script let me know and I can write a demo script for you.
Thanks
Brian
It would be great brian if you can integrate that code. I am just a biginner in VBA.
Hi Bibin, here is some example code that will hopefully get you going. The first function imports and Excel spreadsheet, the function return the tables name. The second function is then sent the table name and then creates a field called table that will hold it.
Let me know if you have any questions.
Brian
Hi all,
Here is a simple script to to it in the current file :
'---------------
Sub Main
Call AppendField() 'Source
End Sub
' Add a field
Function AppendField
Dim Nom As String
Dim LenRight As Integer
LenRight = (Len(Client.CurrentDatabase.Name) - Len(Client.WorkingDirectory))
Name = """" & Right(Client.CurrentDatabase.Name,LenRight) & """"
Set db = Client.CurrentDatabase()
Set task = db.TableManagement
Set field = db.TableDef.NewField
Formule= Name
field.Name = "SOURCE"
field.Description = ""
field.Type = WI_VIRT_CHAR
field.Equation = Name
field.Length = 255
task.AppendField field
task.PerformTask
Set task = Nothing
Set db = Nothing
Set field = Nothing
End Function
'--------------------------------------