+ Reply to Thread
Results 1 to 2 of 2

vba to send data to excel from single clipboard

Hybrid View

  1. #1
    Registered User
    Join Date
    07-04-2010
    Location
    Hawaii
    MS-Off Ver
    Excel 2003
    Posts
    9

    vba to send data to excel from single clipboard

    Aloha , I have written an autohotkey script to parse and rearrange a complex pipe delimited text file . I currently have it working by sending F5 and pasting the R1C1 cell location and then pasting the data etc but it's slow and screen 'flashy'.
    I'd like to call a macro to have it quietly paste the clipboard but I need some help figuring out how to split off the R1C1 info ( which I can have be the first characters in the clipboard string
    and followed by any delimiter ... the rest of the data on the clipboard will be the 'down the column' `r`n cells I am trying to paste.

    all I've got so far is the simple ( I know no vba ) macro for R1C1 = r30c4

    Sub GetClip()
    ActiveSheet.Paste Destination:=Cells(30, 4)
    End Sub
    I removed the worksheet reference above since i just want the activesheet .

    and once i figured out how to find FM20.dll and create a userform to activate it, I can get the snippet from mikerickson at http://www.mrexcel.com/forum/showthread.php?t=321833 to work :

    Dim clipboardData As New DataObject
    Dim clipboardContents As String
    
    clipboardData.GetFromClipboard
    clipboardContents = clipboardData.GetText
    
    MsgBox clipboardContents & vbCr & " is in the clipboard"
    Anybody kind enough to help me with a robust vba macro that will split the clipboard and grab the first part of the string on the clipboard enclosed in parenthesis (%row%,%column%) and assign it to a var1, and remove that data, so I can have the macro then paste the remainder of the clipboard ?
    ActiveSheet.Paste Destination:=Cells(var1)

  2. #2
    Registered User
    Join Date
    07-04-2010
    Location
    Hawaii
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: vba to send data to excel from single clipboard

    I didn't get any responses but did manage to get some help at http://www.experts-exchange.com/Soft...html#a36250099

    I'm posting here in case anybody else is stumped like I was ... it's handy to be able to send the cell address and contents in a single clipboard to excel

    Sub clippy()
    
       Dim strText As String
       Dim varData, varSub
        Dim Clip As Object
        Set Clip = CreateObject( _
         "new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
        
        Clip.GetFromClipboard
        strText = Clip.GetText
       If InStr(1, strText, "|", vbTextCompare) > 0 Then
          varData = Split(strText, "|")
          varSub = Split(varData(1), vbcrlf)
          With Range(Application.ConvertFormula(varData(0), xlR1C1, xlA1))
             .Resize(UBound(varSub) + 1).Value = Application.Transpose(varSub)
          End With
       End If
        
        Clip.SetText "Reddy"
        Clip.PutInClipboard ' when my script sees the clipboard change/contain this word continue
        
        Set Clip = Nothing
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1