Results 1 to 7 of 7

Overcome SAVE AS box in SAP while transferring the report to excel.

Threaded View

ajt0107 Overcome SAVE AS box in SAP... 09-10-2013, 02:16 AM
wenqq3 Re: Overcome SAVE AS box in... 09-10-2013, 03:55 AM
ajt0107 Re: Overcome SAVE AS box in... 09-11-2013, 04:15 AM
ajt0107 Re: Overcome SAVE AS box in... 10-04-2013, 03:37 AM
ajt0107 VB Code to run smart view... 10-04-2013, 04:19 AM
Fotis1991 Re: Overcome SAVE AS box in... 10-04-2013, 04:25 AM
mirmoazam Re: Overcome SAVE AS box in... 05-12-2017, 03:30 AM
  1. #1
    Registered User
    Join Date
    09-09-2013
    Location
    Delhi
    MS-Off Ver
    Excel 2010
    Posts
    9

    Overcome SAVE AS box in SAP while transferring the report to excel.

    Hello

    Am using the below excel VB code to transfer the output from SAP to excel but am encountering an issue at the last step where SAP comes up with SAVE AS dialog box asks the destination/path to save the file. I need this step as a part of automation too......please help

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    Sub Macro2()
    
    Dim Application, Connection, session As Object
    Set SapGuiAuto = GetObject("SAPGUI")
    Set Application = SapGuiAuto.GetScriptingEngine
    Set Connection = Application.Children(0)
    Set session = Connection.Children(0)
    
    Dim AJ As Workbook
    Set AJ = ActiveWorkbook
    '''''SAP
    
    If Not IsObject(Application) Then
       Set SapGuiAuto = GetObject("SAPGUI")
       Set Application = SapGuiAuto.GetScriptingEngine
    End If
    If Not IsObject(Connection) Then
       Set Connection = Application.Children(0)
    End If
    If Not IsObject(session) Then
       Set session = Connection.Children(0)
    End If
    If IsObject(WScript) Then
       WScript.ConnectObject session, "on"
       WScript.ConnectObject Application, "on"
    End If
    
    AJ.Activate
    Dim pern As Long
    pern = 2
    Range(Cells(pern, 1), Cells(pern, 1)).Select
    While ActiveCell.Value <> ""
    If ActiveCell.Value <> "" Then
    Range(Cells(pern, 1), Cells(pern, 1)).Select
    Selection.Copy
    
    
    
    session.findById("wnd[0]").maximize
    session.findById("wnd[0]/tbar[0]/okcd").Text = "/nksbb"
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/usr/lbl[5,10]").SetFocus
    session.findById("wnd[0]/usr/lbl[5,10]").caretPosition = 0
    session.findById("wnd[0]").sendVKey 2
    session.findById("wnd[0]/usr/lbl[12,12]").SetFocus
    session.findById("wnd[0]/usr/lbl[12,12]").caretPosition = 16
    session.findById("wnd[0]").sendVKey 2
    session.findById("wnd[0]/usr/ctxtKOSTL-LOW").Text = Range(Cells(pern, 1), Cells(pern, 1))
    session.findById("wnd[0]/usr/ctxtR_BUDAT-LOW").Text = "07/29/2013"
    session.findById("wnd[0]/usr/ctxtR_BUDAT-HIGH").Text = "08/25/2013"
    session.findById("wnd[0]/usr/ctxtP_DISVAR").Text = "/nd_cesumm"
    session.findById("wnd[0]/usr/ctxtP_DISVAR").SetFocus
    session.findById("wnd[0]/usr/ctxtP_DISVAR").caretPosition = 10
    session.findById("wnd[0]/usr/btnBUT1").press
    session.findById("wnd[1]/usr/txtKAEP_SETT-MAXSEL").Text = "999999999"
    session.findById("wnd[1]").sendVKey 0
    session.findById("wnd[0]/tbar[1]/btn[8]").press
    session.findById("wnd[0]/mbar/menu[0]/menu[3]/menu[1]").Select
    
    session.findById("wnd[0]/tbar[1]/btn[43]").press
    'session.findById("wnd[1]/usr/radRB_OTHERS").SetFocus
    'session.findById("wnd[1]/usr/radRB_OTHERS").Select
    'session.findById("wnd[1]/usr/cmbG_LISTBOX").key = "04"
    'session.findById("wnd[1]/tbar[0]/btn[0]").press
    
    
    
    
    Workbooks.Open Filename:="C:\Documents and Settings\sin21757\Desktop\export.XML"
    ActiveWorkbook.SaveAs Filename:="C:\Documents and Settings\sin21757\Desktop\SAP\" & Range("a3") & ".xls", FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
    ActiveWindow.Close
    pern = pern + 1
    
    
    End If
    Range(Cells(pern, 1), Cells(pern, 1)).Select
    Wend
    
    
    End Sub
    Last edited by arlu1201; 09-10-2013 at 02:22 AM. Reason: Use code tags in future.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 05-30-2012, 06:03 AM
  2. Split Excel report and save separate Workbooks to respective locations
    By seattle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2010, 03:30 AM
  3. Save excel report to PDF using Macro
    By Helen W in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-17-2009, 10:43 AM
  4. Replies: 1
    Last Post: 04-13-2008, 12:27 AM
  5. [SOLVED] how to overcome excel file limitaions (65,000) records only?
    By touresaa in forum Excel General
    Replies: 4
    Last Post: 03-28-2005, 04:06 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