Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, July 8, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Datagrid Export into MS Excel
Olivier
Posts: 10
 
Datagrid Export into MS ExcelYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Aug 06 12:01 PM
fiogf49gjkf0d
I search how to export data from a datagrid into a MS Excel workbook with microsoft vbscript functions (or saleslogix functions). I have no sucess with forum solutions
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Datagrid Export into MS ExcelYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Aug 06 2:29 PM
fiogf49gjkf0d
The way I always do it is to use Excel's built-in CopyFromRecordset function, It is a quick and very easy way to do it.

I posted about it a couple of years ago here:
http://saleslogixblog.com/rfarley/archive/2004/10/13/1094.aspx

-Ryan
[Reply][Quote]
Peter H
Posts: 17
 
Re: Datagrid Export into MS ExcelYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Aug 06 12:04 AM
fiogf49gjkf0d
I used it from the link above, and it worked like a charm (just great).

Thanks for that article Ryan!
[Reply][Quote]
Steve Margeson
Posts: 38
 
Re: Datagrid Export into MS ExcelYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Aug 06 7:35 AM
fiogf49gjkf0d
Here is a custom function that I wrote in VBScript a while back to export a data grid to excel. you are welcome to it.
You may need to clean it up a little.

[BEGIN]
Function ExportDGtoExcel(datagrid,mySheet,myBook,StartCell,FileName,shohidden)
Dim Row
'Create a new workbook in Excel.
'Transfer the field names to Row 1 of the worksheet:
'Note: CopyFromRecordset copies only the data and not the field
' names, so you can transfer the fieldnames by traversing the
' fields collection.
'Get Row number from StartCell
Row = Right(StartCell,len(startcell) -1) + 1
' msgbox row
Dim n
For n = 1 to datagrid.Columns.Count '-1
mySheet.Cells.EntireRow.cells(Row,n).Font.Bold = "True"
mySheet.columns(n).columnwidth = ((datagrid.Columns.Item(n-1).Width)/3)
mySheet.Cells(row, n).Value = datagrid.Columns.Item(n-1).Caption
IF shohidden =0 then
IF datagrid.Columns.Item(n-1).Visible = False then
mySheet.columns(n).hidden = True
End IF
End IF
Next
'Transfer the data to Excel.
mySheet.Range("A" & cstr(row +1)).CopyFromRecordset(datagrid.recordset)
'Save the workbook and quit Excel.
myBook.SaveAs(FileName)
'GC.Collect()
'Close the connection
ExportDGtoExcel= 1
End Function
[END]
[Reply][Quote]
Olivier
Posts: 10
 
Re: Datagrid Export into MS ExcelYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Aug 06 5:59 PM
fiogf49gjkf0d
i have already try this.
when i execute the script i have an error xlApp object require
i work on SalesLogix 6.2.2 French Version and Microsoft Office XP
Thanks for your help
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: Datagrid Export into MS ExcelYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Aug 06 3:05 AM
fiogf49gjkf0d
I don't mean to be rude, but (just to cover the basics) can you confirm that Excel is installed on the machine that is returning the error?

If so, please post the script you are running and the exact error message.

Regards
Phil
[Reply][Quote]
Olivier
Posts: 10
 
Re: Datagrid Export into MS ExcelYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Aug 06 2:48 PM
fiogf49gjkf0d
Hi

I have solve the problem

On my computer it's impossible to create a workbook instance (Set xlWb = xlApp.Workbooks.Add) with file or not file. I don't know where is the Microsoft com Problem.

On another computer i don't have the problem

Thanks

[Reply][Quote]
alexUA
Posts: 23
 
Re: Datagrid Export into MS ExcelYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Feb 10 4:32 AM
Hi Ryan, i have used your script with my modifications and get my Excell document! But it is problem, after document is created program automatically switches(come back) to slx window. But I need that program stay in Excel document window. How can I do this?

Thank you
[Reply][Quote]
Thomas Aussem
Posts: 57
 
Re: Datagrid Export into MS ExcelYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 05 Feb 10 4:42 AM
Hi AlexUA,

i assume that the excel application is still in the background. To make the Excel application visible you have to set the property Visible to True and to maximuze the Excel Window you have to set the WindowState property. Please have a look at the example code below:

Const xlMaximized = -4137
Const xlMinimized = -4140
Const xlNormal = -4143

Dim oExcel, oExcelWB, oExcelSheet

On Error Resume Next
Set oExcel = CreateObject("Excel.Application")
Set oExcelWB = oExcel.WorkBooks.Add
Set oExcelSheet = oExcelWB.WorkSheets("Tabelle1")

oExcel.Visible = True

oExcel.WindowState = xlMinimized
oExcel.WindowState = xlMaximized

' destroy all Excel COM Objects
Set oExcel = Nothing
Set oExcelWB = Nothing
Set oExcelSheet = Nothing

Due to the fact that I have found a lot of issues with mamximizing the window, I do the workaround of first minimizing and then maximizing the window.

Cheers,
Thomas
[Reply][Quote]
alexUA
Posts: 23
 
Re: Datagrid Export into MS ExcelYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 05 Feb 10 7:22 AM
Hi, thanks for your code, but It doesnt help me Maybe because my slx window form is modal? The window realy minimizing and maximizing but at the End stops at slx window...
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 7/8/2025 2:52:54 PM