Solved

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

Posted on 2014-10-01
8
151 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
[X]
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
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

734 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