‎2006 Jun 14 11:19 AM
Hi everyone,
I created a macro in Word.
Now I am calling it successfuly from ABAP using i_oi_document_proxy->execute_macro.
Is there a way to pass a parameter from ABAP to the macro ?
Thanks in advance.
‎2006 Jun 14 11:40 AM
hi
hav u seen this FM
<b>IO_OE_TEST_MACRO</b>
<b>RH_START_WWORD_WITH_DATA</b>
‎2006 Jun 14 11:40 AM
Hi,
Try following logic
INCLUDE OLE2INCL.
DATA EXCEL TYPE OLE2_OBJECT.
DATA WORKBOOK TYPE OLE2_OBJECT.
CREATE OBJECT EXCEL 'Excel.Application'.
CALL METHOD OF EXCEL 'Workbooks' = WORKBOOK.
CALL METHOD OF WORKBOOK 'Open' EXPORTING #1 = 'C:\EX1.XLS'.
Regards
Amole
‎2006 Jun 14 11:51 AM
Hi David,
You can very well pass parameters from ABAP.
Try this.
CALL METHOD document->execute_macro
EXPORTING macro_string = macro_string
param_count = param_count
no_flush = no_flush
IMPORTING error = error
retcode = retcode
CHANGING error_string = error_string
retvalue = retvalue.Regards,
Raghav
‎2006 Jun 14 11:52 AM
Hai David
Check the following Code
DATA: retcode TYPE soi_ret_string VALUE c_oi_errors=>ret_ok.
*
subrc = 0.
*
CALL METHOD proxy->execute_macro
EXPORTING
macro_string = macro_name
param1 = param1
IMPORTING
retcode = retcode
CHANGING
retvalue = retvalue.
IF retcode <> c_oi_errors=>ret_ok.
subrc = 8.
CALL FUNCTION 'HR_BEN_OI_HANDLE_ERROR'
EXPORTING
severity = subrc
reaction = reaction
TABLES
error_table = error_table.
EXIT.
ENDIF.
*
Thanks & regards
Sreenivasulu P
‎2006 Jun 14 12:01 PM
HI
GOOD
GO THROUGH THIS CODE , I HOPE YOU WILL GET SOME HELP YOU SOLVE YOUR PROBLEM.
----
EXAMPLE *
----
REPORT ZVALDATE .
Data: v_date(8).
V_date = '20030102'.
VAL_DATE <DATE> <FORMAT> <-- Passing Parameters
val_date v_date 'YYYYMMDD'.
if sy-subrc = 0.
write: 'Valid Date' .
elseif sy-subrc = 1.
write: 'Invalid Date' .
elseif sy-subrc = 2.
write: 'Invalid Date Format' .
endif.
----
END OF REPORT *
----
******************************************************
To use the macro "VAL_DATE" GLOBALLY, Insert the *
below 2 macros in table TRMAC using Txn SM30. *
----
Sytax : *
VAL_DATA <Date> <Date format>. *
It return sy-subrc. *
0 => Valid date - as per the specified format*
1 => Invalid date *
2 => Invalid date format *
*
<Date format> : *
You can pass the following date formats *
DDMMYYYY MMDDYYYY YYYYMMDD YYYYDDMM *
----
Macro VAL-DATE *
This macro validate Date according to the specified*
format. *
Created by Abhishek Kumar *
abhi4r@yahoo.com *
----
define val-dat.
clear: %_date1, %_date2.
%_date1(4) = &1. "Year
%_date1+4(2) = &2. "Month
%_date1+6(2) = &3. "Date
%_date2 = %_date1 - 1.
%_date2 = %_date2 + 1.
if %_date1 <> %_date2.
sy-subrc = 1.
else.
sy-subrc = 0.
endif.
end-of-definition.
----
Macro VAL_DATE *
Created by Abhishek Kumar *
abhi4r@yahoo.com *
----
define val_date.
data %_date1 like sy-datum.
data %_date2 like sy-datum.
data %_date3(8).
case &2.
when 'DDMMYYYY'.
val-date &14(4) &12(2) &1+0(2).
when 'MMDDYYYY'.
val-date &14(4) &10(2) &1+2(2).
when 'YYYYMMDD'.
val-date &10(4) &14(2) &1+6(2).
when 'MMYYYYDD'.
val-date &12(4) &10(2) &1+6(2).
when others.
sy-subrc = 2.
endcase.
end-of-definition.
THANKS
MRUTYUN
‎2006 Jun 14 5:16 PM
Hi evryone,
Thanks for the help.
But there is still something I cannot perform.
When I pass the parameter to the param1 value of the execute_macro method, I want my macro to receive this param1.
What is the step at the macro level ?
Thanks.
‎2007 Jan 24 1:41 PM
This is an old question, i know, but for the next one who searches for this topic:
You should just declare a macro in your document (word here) with the parameters.
Public Sub Testmacro(str As String, int1 As Integer)
MsgBox str 'Display the string
MsgBox int1 'Display the number
End Subyou can pass these parameters in their specified order.
greets,
stefan