Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSFlexGrid to EXCEL....

Status
Not open for further replies.

aliinal

Technical User
Jun 26, 2001
104
TR
Is it possible to save (or send) the entire data in a MsFlexGrid control to EXCEL?
I need to save background colors, font styles, column widths etc. etc.

thanks for your help.
 
Private Sub cmdExcel_Click()
Dim iRow As Integer, iCol As Integer

With Grid
iRow = .Row: iCol = .Col
.Row = 0: .Col = 0
.RowSel = .Rows - 1: .ColSel = .Cols - 1
Clipboard.SetText .Clip
.Row = iRow: .Col = iCol
End With

Dim xlAppl As Excel.Application
Set xlAppl = New Excel.Application
With xlAppl
.Visible = True
.Workbooks.Add
.ActiveSheet.Paste
End With
End Sub
Eric De Decker
vbg.be@vbgroup.nl

 
:(
Didn't worked...

I get an error user defined type not defined error...

why ???

pls help me
 
It is always useful to tell the line that gives you the error...

My guess is that you didn't include the Excel object library into your project.

Go to the Project Menu, Select References at the bottom of this menu and when they show up check the box for Microsoft Excel xx Object Library _________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
I've solved that problem but another occured...
it doesn't paste excel the correct data(grid's data)
it pastes the last text i've copied.
I understand that copying form msflexgrid procedure don't work...

I need help again.
thanks...
 
I've solved that problem but another occured...
it doesn't paste excel the correct data(grid's data)
it pastes the last text i've copied.
I understand that copying from msflexgrid procedure don't work...

I need help again.
thanks...
 
Hi.
You should try making a for---next to capture the data on your grid (and then pass it to variables or hidden text boxes) and then send it to Excel.
For nCounter = 1 to MSFlexGrid.Rows
MSFlexGrid.col = 1
x = MSFlexGrid.Text
-----
-----
Then send it to Excel...
Next

Search the Microsoft CD for a file called Vbaxl8.hlp (or something close). You'll find all you need to know.

Have fun!!!
 
By dzidze's advice, i tried to send all data to excel cell-by-cell

a simple for loop for columns, and one for rows inside it. And set excel's cell's all properties to flexgrids properties. like
excel.range(cells(i,j),(cells(i,j)).interior.color = msflexgrid.cellbackgroundcolor

and many lines for all other properties like fontbold italic etc.etc.

this seems to work but its very very slow even on a 860 Mhz Pentium III.
But i'm writing this program for a P75 :(

can anyone advice me a faster way???
 
nobody knows it???

i don't belive...

pls help me!!
Copying it from Flexgrid and then pasting it to Excel was a nice idea.

pls some more ideas...
 
Hi aliinal.

I'm having the same problem with a similar project. The coding ain't that big, but it's true that it does seem to take some time. And I'm working on a P3-900.

If I ever find anything to make it faster I'll let you know.
Of course, if anybody has a solution, they can post it so we can see it...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top