Excel to Ldif 
Author Message
 Excel to Ldif

Hi,

I'm trying to build a script for transforming an Excel
Worksheet into a Ldif file that could be imported in AD
(csvde does not work for this)

Does one have such a script ?
here is the beginning:

xlfile = "c:\import.xls"
set xlObj = Wscript.CreateObject("EXCEL.application")
xlObj.Visible = True
xlObj.workbooks.open(xlFile)
xlObj.sheets("import").Activate
xlObj.ActiveSheet.range("A1").Activate
y=0
do while xlObj.activecell.value <> ""
xlobj.activecell.offset(y,0).Activate
y = y + 1
loop
wscript.echo y
Here, I have the number of columns that are in use;
now I need to couple this with a function that would
parse those columns for each non-empty cell.

Thanks in advance for your help

Bruno

ps: perl is welcome also.



Sat, 30 Jul 2005 21:31:31 GMT  
 Excel to Ldif
Hi,
sorry but the included script is not the good one;
Here is the good one

TextXL = "c:\import.xls" 'excel worksheet

set fso = wscript.createobject
("scripting.filesystemobject")
set ofile = fso.opentextfile("c:\temp.ldif",8,true)

set oXL = wscript.createobject("Excel.application")
oxl.visible= false
oXL.Workbooks.open textxl
oXL.Sheets("import").Activate 'first sheet is named import
oxl.ActiveSheet.Range("A1").Select

x=0
myattrib = ""
atts = getattrib()
mylistofattributes = split(atts,"|")
upper = Ubound(Mylistofattributes) -1
wscript.echo upper ' number of fields behind dn:
for i = 0 to Ubound(Mylistofattributes)-1
wscript.echo mylistofattributes(i)
next
Mylistofattributes = ""

function getattrib()
Do Until IsEmpty(oxl.ActiveCell)
oxl.ActiveCell.Offset(0, 1).Select
myattrib = myattrib & "|" & oxl.Activecell.value
Loop
getattrib = myattrib
end function
set oXL = nothing

Quote:
>-----Original Message-----
>Hi,

>I'm trying to build a script for transforming an Excel
>Worksheet into a Ldif file that could be imported in AD
>(csvde does not work for this)

>Does one have such a script ?
>here is the beginning:

>xlfile = "c:\import.xls"
>set xlObj = Wscript.CreateObject("EXCEL.application")
>xlObj.Visible = True
>xlObj.workbooks.open(xlFile)
>xlObj.sheets("import").Activate
>xlObj.ActiveSheet.range("A1").Activate
>y=0
>do while xlObj.activecell.value <> ""
>xlobj.activecell.offset(y,0).Activate
>y = y + 1
>loop
>wscript.echo y
>Here, I have the number of columns that are in use;
>now I need to couple this with a function that would
>parse those columns for each non-empty cell.

>Thanks in advance for your help

>Bruno

>ps: perl is welcome also.
>.



Sun, 31 Jul 2005 01:29:00 GMT  
 Excel to Ldif
Hi,
I changed some stuff; and it's already closer to what I
need: the problem is that I can't get more than two rows
appear (moves only one row down). Any help appreciated
Brgds,

Bruno

TextXL = "c:\import.xls"

set fso = wscript.createobject
("scripting.filesystemobject")
set ofile = fso.opentextfile("c:\temp.ldif",8,true)

set oXL = wscript.createobject("Excel.application")
oxl.visible= false
oXL.Workbooks.open textxl
oXL.Sheets("import").Activate
oxl.ActiveSheet.Range("A1").Select

'list of attributes in header (works fine)
x=0
myattrib = ""
atts = getattrib()
mylistofattributes = split(atts,"|")
upper = Ubound(Mylistofattributes) -1 '(dn is always
listed and not comprised in upper)
wscript.echo upper
for i = 0 to Ubound(Mylistofattributes)-1
wscript.echo mylistofattributes(i)
next

Oxl.activesheet.range("A1").Select

do Until IsEmpty(oxl.ActiveCell) 'stops after one move !
oxl.activecell.offset(1,0).Activate
getuserprop()
Loop

function getattrib()
Do Until IsEmpty(oxl.ActiveCell)
oxl.ActiveCell.Offset(0, 1).Select
myattrib = myattrib & "|" & oxl.Activecell.value
Loop
getattrib = myattrib
end function

function getuserprop()
dn = oxl.activecell.offset(0,0).value
wscript.echo dn
for i = 1 to upper         'does not work
oxl.Activecell.offset(0,1).select
wscript.echo oxl.activecell.value
next
getuserprop = userattrib
end function

oxl.application.quit
set oXL = nothing



Sun, 31 Jul 2005 21:36:05 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. open doc/excel file in frame with Word/Excel menubar

2. Applying Excel Autofilter when opening Excel Files

3. Open Excel File (Excel.Application)

4. Urgent - Check the installation of EXCEL or EXCEL Viewer on Client

5. need help: Open Excel, run macro, save file, close Excel

6. Open Excel File (Excel.Application)

7. Parsing Excel file in a browser window and Excel menubar

8. Response.contenttype = application/vnd.ms.excel and Excel XP

9. Urgent - Check the installation of EXCEL or EXCEL Viewer on Client

10. How can I open an excel file in Excel?

11. Install Excel Object Library w/out full Excel program?

12. filename error when trying to open a report into excel via vbscript

 

 
Powered by phpBB® Forum Software