+ Reply to Thread
Results 1 to 7 of 7

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

Hybrid View

  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.

  2. #2
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

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

    Application.DisplayAlerts = False 'IT WORKS TO DISABLE ALERT PROMPT
    Dim AJ As Workbook
    YOUR CODE
    
    Application.DisplayAlerts = True 'RESETS DISPLAY ALERTS
    
    End Sub
    OR

    ActiveWorkbook.SaveAs Filename:="C:\Documents and Settings\sin21757\Desktop\SAP\" & Range("a3") & ".xls", FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
    ActiveWorkbook.saved = true
    ActiveWindow.Close
    Last edited by wenqq3; 09-10-2013 at 03:59 AM.
    -If the problem is solved, please mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved".

    -Always upload a workbook before start your question
    To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

    +++ If my answer(s) helped you, please add me reputation by click on * +++

  3. #3
    Registered User
    Join Date
    09-09-2013
    Location
    Delhi
    MS-Off Ver
    Excel 2010
    Posts
    9

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

    thanks for the instant reply but my concern was to overrule the "save as" pertains to SAP.......the steps am performing are as follows
    1.executing report in SAP by feeding in relevant parameters.
    2.output comes up.
    3.saving the report in spreadsheet form....at this point the SAVE AS dialog box pops up in SAP to save the file at desired destination. Once my loop hits this step, everytime I have to save the file manually and then loop moves on further.I want to overcome the step of SAVE AS dialog box.....macro should save the file automatically which am not able to accomodate in my automation steps.

  4. #4
    Registered User
    Join Date
    09-09-2013
    Location
    Delhi
    MS-Off Ver
    Excel 2010
    Posts
    9

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

    Is there any one who can help me on my below concern????

  5. #5
    Registered User
    Join Date
    09-09-2013
    Location
    Delhi
    MS-Off Ver
    Excel 2010
    Posts
    9

    VB Code to run smart view (hyperion) from Excel 2010

    Can anybody help me with the VB code to run Hyperion from Excel 2010?

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

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

    @ ajt0107

    Pls don't bump your thread every 1 hour. we can be elastic to forum rules but not so much....

    If your question has not been answered within a day, consider adding another post with any additional information you believe is relevant. If you think your post is good as is, just reply to your own thread with the words "Bump no response", which will bring it to the top of the forum.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  7. #7
    Registered User
    Join Date
    10-16-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    1

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

    Dear Ajit,

    Did you find a solution to this problem. i'm facing the same issue with SAP 7.10 and I don't have an option to upgrade SAP to apply an alternate solution
    Regards
    Mir

+ 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. 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