473,473 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

i want to send data from microsoft office excel 2007 to msflexgrid?

2 New Member
hi all,

how can send data from microsoft office excel 2007 to msflexgrid?
example i want send data form A1-D1 in excel to msflexgrid.

help me from this code. thanks
Sep 3 '11 #1
3 2913
Guido Geurs
767 Recognized Expert Contributor
EXCEL=
Copy the cells to the clipboard with command or macro in Excel:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CommandButton1_Click()
  2.     Range("a1: d3").Copy
  3. End Sub
VB6 form=
Paste the clipboard in a hidden textbox (Text1) in VB6.
Split the Text1.text in lines in an array and add the lines in the MSflexgrid.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Dim ARRAYLINES As Variant ' array with the lines
  3. Dim ARRAYCELLS As Variant ' array with the cells of 1 line to count the cols needed
  4. Dim LINES As Integer
  5.    With Text1
  6.       .Text = Clipboard.GetText
  7.       ARRAYLINES = Split(.Text, vbNewLine)
  8.    End With
  9.    ARRAYCELLS = Split(ARRAYLINES(0), vbTab)
  10.    With MSFlexGrid1
  11.       .Cols = UBound(ARRAYCELLS) + 1
  12.       For LINES = LBound(ARRAYLINES) To UBound(ARRAYLINES)
  13.          .AddItem (ARRAYLINES(LINES))
  14.       Next
  15.    End With
  16. End Sub
  17.  
Sep 7 '11 #2
ashaka
2 New Member
thanks for your responded but there is problem when i click command button appears debug "method range of object_global failed" and when i click command1 appears error in "arraycells = split(arraylines (0), vbtab)". sorry, i am still new with vb. thanks for responded.
Sep 14 '11 #3
Guido Geurs
767 Recognized Expert Contributor
This is working for me: Office 2003 and vb6 SP6. (see attachment).
Added some clears and error traps.
AXCEL=
Expand|Select|Wrap|Line Numbers
  1. Private Sub CommandButton1_Click()
  2.     Application.CutCopyMode = False
  3.     Range("a1: d3").Copy
  4. End Sub
VB6=
Expand|Select|Wrap|Line Numbers
  1. Private Sub Com_Clear_Click()
  2.    Text1.Text = ""
  3. End Sub
  4.  
  5. Private Sub Com_ClearGrid_Click()
  6.    MSFlexGrid1.Rows = 1
  7. End Sub
  8.  
  9. Private Sub Com_Paste_Click()
  10. Dim ARRAYLINES As Variant ' array with the lines
  11. Dim ARRAYCELLS As Variant ' array with the cells of 1 line to count the cols needed
  12. Dim ARRAYLINESidx As Integer
  13.    '§ put clipboard in textbox
  14.    With Text1
  15.       .Text = Clipboard.GetText
  16.       If .Text = "" Then
  17.          MsgBox "No data in clipboard"
  18.          Exit Sub
  19.       Else
  20.          ARRAYLINES = Split(.Text, vbNewLine)
  21.       End If
  22.    End With
  23.    '§ put textbox in grid
  24.    If ARRAYLINES(0) = "" Then
  25.       MsgBox "No data"
  26.       Exit Sub
  27.    Else
  28.       ARRAYCELLS = Split(ARRAYLINES(0), vbTab)
  29.       With MSFlexGrid1
  30.          .Cols = UBound(ARRAYCELLS) + 1
  31.          .Rows = 1 '§ keep header
  32.          For ARRAYLINESidx = LBound(ARRAYLINES) To UBound(ARRAYLINES) - 1
  33.             .AddItem (ARRAYLINES(ARRAYLINESidx))
  34.          Next
  35.       End With
  36.    End If
  37.    '§ clear array
  38.    ReDim ARRAYLINES(0)
  39.    ReDim ARRAYCELLS(0)
  40. End Sub
  41.  
  42. Private Sub Com_Show_Click()
  43.    Text1.Visible = True
  44. End Sub
  45.  
  46. Private Sub Com_Hide_Click()
  47.    Text1.Visible = False
  48. End Sub
Sep 14 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: tel4 | last post by:
Microsoft Visual Studio Tools for the Microsoft Office System 2003 Microsoft Corp. DATE......: 03-10-2003 TYPE......: Application OS........: WinALL DiSKS.....: xx/02 PROTECTiON : NONE/RETAiL...
5
by: Michael Russell | last post by:
Hi all, Using C#, I've created a simple wrapper class for using Excel. I have Office Pro 2003 installed on my devel machine. The wrapper class works great, reading and writing to/from Excel. ...
1
by: =?Utf-8?B?S2FydGd1cmw3MjQ=?= | last post by:
I get the following error when I try to remove it from my system: "The language of this installation package is not supported by your system" It has 327 mb of ram tied up and it will not let me...
0
by: nmsreddi | last post by:
Hi friends, I have downloaded mosss2007 and installed successfully ,but the problem is while starting the services of the server ,it is displaying the error as "database connection failure" ...
5
by: abb | last post by:
On a Vista machine, the following code works using the ASP.NET Development Server, but fails in IIS7: book = excel.Workbooks.Open(tempfile, false, false, Missing.Value, Missing.Value,...
0
by: =?Utf-8?B?ZGlzcGxheW5hbWU=?= | last post by:
The following code used to outputs to Excel 2003 fine. Do I need to change it to output to Excel 2007? <% Response.ContentType = "application/vnd.ms-excel" Response.AddHeader...
0
by: Luft | last post by:
I'm just starting to work with VSTO and Word 2007 but I've run into a problem when trying to create an add-in. I get the warning: This project references the primary interop assembly for Microsoft...
0
by: PrashanthVasa | last post by:
Hi, I am Unable to instantiate the Communicator API from Microsoft Office Communicator 2007 R2 custom tab XBAP application. I am getting Com Exception due to security permission. Can some please...
0
by: lenniekuah | last post by:
Hullo Friends, I need your help. Please help me. I am using C#NET2008 and Microsoft Office 2003 Excel Spreadsheet. On Excel Spreadsheet at Row 1 I am trying to merge the row 1 cells from 1 to 5...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.