Solved

VB6 paste clipboard into MSHFlexgrid

Posted on 2013-06-02
2
1,242 Views
Last Modified: 2013-06-02
Hi again

I have this script that past all values into a column in my MSHFlexgrid

Dim lRows As Long
    Dim sText As String
      sText = Clipboard.GetText
      lRows = UBound(Split(sText, vbCr)) + 1
      With MSHFlexGrid2
        .Rows = .FixedRows + lRows
        .Row = .FixedRows
        .Col = .FixedCols  '(or whatever value you like)
        .RowSel = .Rows - 1
        .Clip = Replace(sText, vbLf, "")
      End With

Open in new window


But this is if i copy value from a same column.

I would like to now copy into clipboard data from 2 columns and it would paste it into 2 columns in my MSHFlexgrid.

Ex:
if i copy this below from my excel file:
Col1          Col2
1               a
2               b
3               c
4               d
5               e


When i paste into my MSHFlexgrid it will paste it into 2 columns:
1               a
2               b
3               c
4               d
5               e


How can i do that?

thanks again
0
Comment
Question by:Wilder1626
2 Comments
 
LVL 15

Accepted Solution

by:
eemit earned 500 total points
ID: 39215240
Try this:

  Dim nFixedRows As Long
  Dim nFixedCols As Long
  Dim nRows As Long
  Dim nCols As Long

  nFixedRows = 1
  nFixedCols = 0

  sText = Clipboard.GetText

  nRows = UBound(Split(sText, vbCr)) + 1
  
  'Dim vRows As Variant
  'vRows = Split(sText, vbCr)
  'nCols = UBound(Split(vRows(0), vbTab)) + 1
  nCols = UBound(Split(Split(sText, vbCr)(0), vbTab)) + 1
  'Debug.Print nCols

  With MSHFlexGrid2
      .FixedRows = nFixedRows
      .FixedCols = nFixedCols
        
      .Rows = .FixedRows + nRows
      .Cols = .FixedCols + nCols
      .Row = .FixedRows
      .Col = .FixedCols  '(or whatever value you like)
        
      .RowSel = .Rows - 1
      .ColSel = .Cols - 1
        
      .Clip = Replace(sText, vbLf, "")
  End With

Open in new window

0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 39215246
Thanks for your help, this is perfect
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now