+ Reply to Thread
Results 1 to 3 of 3

Copy a table from SAP and insert it into active excel sheet

  1. #1
    Registered User
    Join Date
    07-22-2015
    Location
    Dresden, Germany
    MS-Off Ver
    Prof + 2010
    Posts
    1

    Question Copy a table from SAP and insert it into active excel sheet

    Hello Guys,

    I created a macro which runs a SAP transaction. The outcome of the transaction is a SAP screen which shows a table. I would like to copy that table and paste it into my active excel sheet. In total I will need the following steps:

    1. Run report
    2. Select the table/ needed cells in SAP
    3. Copy Selection
    4. Paste selection

    I already did step 1 and 2 and they work. Unfortunately, I don't know the command to copy my SAP selection (3).

    My Code:
    'call transaction
    session.findById("wnd[0]").maximize
    session.findById("wnd[0]/tbar[0]/okcd").Text = "/n/SIE/E_P_ORDER1"
    session.findById("wnd[0]").sendVKey 0

    'entries for dates etc..
    .
    .

    'select data
    session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").SelectAll

    'copy data (I need help here!)

    'paste data
    Cells(2,2) = ....

    I appreciate any Help!
    Thank you,
    David
    Last edited by DavidBor.; 07-22-2015 at 11:24 AM.

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,176

    Re: Copy a table from SAP and insert it into active excel sheet

    I use CopyFromRecordset.
    But you need to use ADO ,and know the server/user/passowrd to pull the data.

    Your code looks like a COPY / paste.

  3. #3
    Registered User
    Join Date
    07-10-2014
    Location
    Mexico
    MS-Off Ver
    2010
    Posts
    1

    Re: Copy a table from SAP and insert it into active excel sheet

    Hello;

    I had had a simmilar situation and with some help I was able to solved it, here is the example you can use as guide:

    As you will see, you need to know the names of the headers columns in order to be able to select them. I don't know which version of SAP are you using.

    Version 7.30 of SAP contains SAP NWBC Propertycollector tool (this can help you to know the headers)

    Your code.......
    Please Login or Register  to view this content.
    I hope this give you an idea about how to select the shell objects in SAP

    Regards

    Trafalgar_x

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy from other excel sheet and paste in current active excel using VBA
    By pradeepsavanur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2014, 06:43 AM
  2. Replies: 1
    Last Post: 01-04-2014, 06:37 PM
  3. How to copy the cells from one active sheet to another active sheet
    By pranav.y in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-06-2013, 09:42 AM
  4. copy next cell when excel sheet active
    By anilg0001 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-06-2013, 06:52 AM
  5. Replies: 1
    Last Post: 01-07-2013, 12:23 AM
  6. Copy and insert to active row
    By Tezza Jay in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-22-2010, 03:56 PM
  7. Copy from active sheet and paste into new sheet using info from cell in active
    By Ingve in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2006, 06:00 PM

Tags for this Thread

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