Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB6 paste clipboard into MSHFlexgrid

Posted on 2013-06-02
2
Medium Priority
?
1,466 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
[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
2 Comments
 
LVL 15

Accepted Solution

by:
eemit earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…
Suggested Courses

636 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