Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


VB6 - Copy all cells from a specific row to clipboard.

Posted on 2014-10-01
Medium Priority
Last Modified: 2014-10-01

I would like to know how i can copy to clipboard all cells from a selected row in my MSHFlexgrid1, and when i will paste this in excel, all MSHFlexgrid cells will go in different cells in excel.

Is that possible?

Thanks again for your help.
Question by:Wilder1626
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
LVL 11

Author Comment

ID: 40355632
I think i have it.

something like this would do it:
    Dim str As String, i As Integer
    With MSHFlexGrid1
        For i = 0 To .Cols - 1
            str = str & .TextMatrix(1, i) & vbTab
        Next i
        Clipboard.SetText (str)
    End With

Open in new window

LVL 49

Accepted Solution

Martin Liss earned 2000 total points
ID: 40355642
Try this. Before you do set the grid's SelectionMode to flexSelectionByRow ( or 1)

    Clipboard.SetText MSHFlexGrid1.Clip
LVL 49

Expert Comment

by:Martin Liss
ID: 40355645
That of course is just the copying part. In order to do the rest i need to know where this is being done? Is the code in a VB6 project and you want to update a sheet in an existing workbook?
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 49

Expert Comment

by:Martin Liss
ID: 40355650
The copy to Excel could be as simple as this.

    ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, _
        DisplayAsIcon:=False, NoHTMLFormatting:=True
LVL 11

Author Comment

ID: 40355951
Yes, this all start in my MSHFlexgrid. That is were i will do the copy thing.

Once i click in the row, it will copy all the cells to clipboard.

Then, i would go in Excel and just paste the values.
LVL 49

Expert Comment

by:Martin Liss
ID: 40355993
That's what my two code snippets do.
LVL 11

Author Closing Comment

ID: 40356004
Thanks again for your help. This is perfect
LVL 49

Expert Comment

by:Martin Liss
ID: 40356019
You're welcome.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question