Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SAP DOI Problem: Failing to set document title & Failing to execute macro

Hello, this is my first post here in this board and I have the following problem:

I have an Excel Spreadsheet, which is stored in SAP (We are using SAP Gui 7300.1.2.1078, Patchlevel 2). This Spreadsheets contains (several) macros, which i want to run after having filled the table with data, in order to show some diagrams. The document is opened perfectly and also the data input from ALV-Grid into the Excel Sheet works great. Problems appear whenever I want to execute the contained macro (Only in Office 2007!!! Office 2010/2013 are working perfectly fine).

Neither defining the EXPORT Parameter "startup_macro" nor running the "execute_macro" function is executing any macro. If I build a workaround for this problem, by firing the macro via timer, just an error appears. I figured out, that the error mainly comes from the document title, given to the document by SAP. I'm defining the document title as Path + Filename, but SAP is stripping out all "\" and ":" characters and adds an "Tabelle von" respectively "Table from" in front of the desired document_title. Excel then has problems, finding and running the macro.

My research has shown, that in every run, the method "SetDocumentTitle" fails. Could you please help me? Find some code snippets below:

SAP:

CALL METHOD control->get_document_proxy

   EXPORTING document_type = 'Excel.Sheet.8'

               document_format = 'OLE'

               no_flush      = ' '

*             REGISTER_CONTAINER = 'X'

     IMPORTING document_proxy = document

               error = error.

CONCATENATE 'FILE://' wa_file INTO url.

   document_title = wa_file.  "wa_file=C:\Temp\ExcelFile.xls

  CALL METHOD document->open_document

     EXPORTING

      document_title   = document_title

      document_url     = url

      no_flush         = 'X'

      open_inplace     = 'X'

      open_readonly    = ' '    "flag_open_readonly

*    PROTECT_DOCUMENT = ' '

      STARTUP_MACRO    = 'start123'

*    USER_INFO        = user_info

*    ONSAVE_MACRO     =

     IMPORTING

      error            = error

      retcode          = retcode.

Excel-VBA:

Sub Workbook_Activate()

    Call start123

End Sub

Sub start123()

    TimeToRun = Now + TimeValue("00:00:02")

    Application.OnTime TimeToRun, "starter"

End Sub

Thank you in advance, regards,

Stephan

P.S.: I forgot to mention, that in all Excel security measures have been deactivated in order to eliminate this source of failure....

P.S. added

Tags:
Not what you were looking for? Ask a question