Page 1 of 1

Too lazy to copy?

Posted: Sat Oct 10, 2009 3:38 pm
by Wim Gielis
Hi there

Just playing around a bit... :D

Yet another method to transfer data to TM1 (although there are abviously better methods out there).

Open a view in a cube viewer (for instance using Architect) and put your cursor on a cell where you'd want to copy a bunch of cells from Excel.

Use a bit of code in VBA:

Code: Select all

Sub CopyToTM1()
    [A1].Copy 'or: [B2].CurrentRegion.Copy, or refer to another sheet, or make it even more dynamic
    AppActivate "Cube Viewer: SERVER NAME->CUBE NAME->VIEW NAME" 'change over here: it should be the window caption of your cube view
    Application.SendKeys "^v" 'mimick Ctrl-V
    AppActivate Application.Caption
    Application.CutCopyMode = False 'take away the ants trace
End Sub
Using the clipboard:

Code: Select all

Sub CopyToTM1()
    Dim DataObj As New MSForms.DataObject
    DataObj.SetText 1000
    DataObj.PutInClipboard
    AppActivate "Cube Viewer: SERVER NAME->CUBE NAME->VIEW NAME"
    Application.SendKeys "^v"
    AppActivate Application.Caption
End Sub
If you use the clipboard in VBA, add a reference to Microsoft Forms 2.0 Object Library (see Tools > References, it's on top of the list usually)

or simply:

Code: Select all

Sub CopyToTM1()
    AppActivate "Cube Viewer: SERVER NAME->CUBE NAME->VIEW NAME"
    Application.SendKeys "1000"
    AppActivate Application.Caption
End Sub
Perhaps this could be useful in other programs than Excel?

Wim