Solved

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

Posted on 2014-10-01
8
147 Views
Last Modified: 2014-10-01
Hi

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.
0
Comment
Question by:Wilder1626
  • 5
  • 3
8 Comments
 
LVL 11

Author Comment

by:Wilder1626
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

0
 
LVL 47

Accepted Solution

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

    Clipboard.Clear
    Clipboard.SetText MSHFlexGrid1.Clip
0
 
LVL 47

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?
0
Industry Leaders: 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!

 
LVL 47

Expert Comment

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

    Range("A1").Select
    ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, _
        DisplayAsIcon:=False, NoHTMLFormatting:=True
0
 
LVL 11

Author Comment

by:Wilder1626
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.
0
 
LVL 47

Expert Comment

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

Author Closing Comment

by:Wilder1626
ID: 40356004
Thanks again for your help. This is perfect
0
 
LVL 47

Expert Comment

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

Featured Post

Industry Leaders: 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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

713 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