OLE Automation with Excel
Hi All,
Does anyone know of any reference/help/material on how to use OLE automation to download and format data from ABAP to Excel.
I need to know what the available methods and properties are so I could format the data the way I want.
Any help will be greatly appreciated.
Regards.
Hi Aurang
You can call almost all methods using OLE. What is required is to know how to interpret a script to ABAP OLE call. This is explained in the tutorial<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1d54348-0601-0010-3e98-bd2a2dcd9e6c">"An Easy Reference For OLE Automation"</a>
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>
Similar Messages
-
RE: Ole Automation with forte.
Tran,
Here is a piece of code(using Forte Version 3OF2 & Word 97) that we've
used to determine if there is already an instance of Word running:
// Create an instance of a Word Application and activate it.
// If an a Word application exists, just activate it.
if ( aTasks <> NIL and aTasks.Exists(aWordApplication.Name) )
then
aWordApplication.visible = TRUE;
aWordApplication.Activate();
else
aWordApplication = new();
aTasks = new();
aWordApplication.CreateUsingProgID( 'word.application'
aWordApplication.visible = TRUE;
aWordApplication.Activate();
aTasks is an attribute of type Tasks on our window & aWordApplication is
an attribute of type _Application on our window. This code will work if
there already is an instance of Word that was started from a Forte
applicaiton. It doesn't recognize a instance of Word that was started
outside of a Forte app. Hope this helps!!
From: Quy Tran[SMTP:[email protected]]
Sent: Wednesday, May 20, 1998 11:17 PM
To: [email protected]
Subject: Ole Automation with forte.
Good Day forte users,
I'm trying to invoke MSWord from a forte application.
I set the objectreference using CreateUsingProgId(This is the only way
that I could get it to work).
The problem is when using CreateUsingProgId, forte will create another
instance of Word. Is there a way to know if the instance already
exists
and retrieve the objectreference of that instance?
Any help would be appreciated.
Thanks
Quy Tran
Lumley Technology
Analyst/Programmer
[email protected]
Ph : 612 93186722
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive
<URL:http://pinehurst.sageit.com/listarchive/>
If you are not the intended recipient, please notify the Sender.
Non-business opinions may not reflect opinions of Piper JaffrayHi Aurang
You can call almost all methods using OLE. What is required is to know how to interpret a script to ABAP OLE call. This is explained in the tutorial<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1d54348-0601-0010-3e98-bd2a2dcd9e6c">"An Easy Reference For OLE Automation"</a>
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a> -
Ole Automation with forte.
Good Day forte users,
I'm trying to invoke MSWord from a forte application.
I set the objectreference using CreateUsingProgId(This is the only way
that I could get it to work).
The problem is when using CreateUsingProgId, forte will create another
instance of Word. Is there a way to know if the instance already exists
and retrieve the objectreference of that instance?
Any help would be appreciated.
Thanks
Quy Tran
Lumley Technology
Analyst/Programmer
[email protected]
Ph : 612 93186722
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>Hi!
I am not sure that I can give you any "golden rules" for interfacing
with OLE, but I can give you some thoughts on where to look for problems
that can result in Segmentation Violations.
I have often seen segmentation violations arise as a result of a NIL
object. You might want to try turning on the trc:lo:25 trace flag to
see if there is a NIL object exception being raise right before the seg
v. You have to be careful with the trc:lo:25 flag, though, since it
will show you every exception, no matter what, that is raised within
Forte (even if it's been handled internally). This is of greater
significance to OLE projects, since Forte tries several different ways
of starting an OLE server and uses internally handled exceptions to
notify itself if a certain method failed.
Another thing to try is just-in-time debugging. You will need Microsoft
Visual C++ installed on the machine where the OLE code is running, and
you will need to set the FORTE_NOHANDLER environment variable to TRUE.
In the MSVC development environment, go to the Tools --> Options
properties sheet, and choose the Debug tab. On that tab, make sure that
Just-In-Time Debugging is selected. Then, run the application. When
you encounter the seg v, you should get a dialog box asking if you want
to debug the application. Choosing yes (actually, I think that pressing
Cancel does this - the dialog box tells you) will bring you into the
MSVC development environment, where you can try some intense debugging.
I hope this helps!
-Katie
[email protected] wrote:
>
Has anybody used Forte to communicate with external components using
OLE
Automation? We are creating segmentation violations through some of
our
use of this interface, and need to know if there are some 'golden
rules'
that can guide developers as they use the feature.
Thank you!--
Katie Carty
Forte Consulting
4801 Woodway Drive
Suite 300E
Houston, Texas 77056
vmail: 510-986-3802
email: [email protected]
----------------------------------------------- -
OLE Integration with Excel --- Urgent
Hello,
i want to draw two charts on Excel sheet based on some data in SAP. in the excel sheet first i have to display the data and then draw the chart for that. now i am able to draw first chart but not able to draw the second chart because i think the area where i have drawn my first chart is active and not able to print the data related to second chart. can any one tell me, how to activate the sheet after drawing first graph.
Thanks a lot in advance...
MohanMohan,
Try this....
You can activate using ...CALL METHOD OF gs_activesheet 'Activate' .
Report ZTEST.
INCLUDE ole2incl .
DATA: gs_excel TYPE ole2_object ,
gs_wbooklist TYPE ole2_object ,
gs_application TYPE ole2_object ,
gs_wbook TYPE ole2_object ,
gs_activesheet TYPE ole2_object ,
gs_sheets TYPE ole2_object ,
gs_newsheet TYPE ole2_object ,
gs_cell1 TYPE ole2_object ,
gs_cell2 TYPE ole2_object ,
gs_cells TYPE ole2_object ,
gs_range TYPE ole2_object ,
gs_font TYPE ole2_object ,
gs_interior TYPE ole2_object ,
gs_columns TYPE ole2_object ,
gs_charts TYPE ole2_object ,
gs_chart TYPE ole2_object ,
gs_charttitle TYPE ole2_object ,
gs_charttitlechar TYPE ole2_object ,
gs_chartobjects TYPE ole2_object .
DATA gv_sheet_name(20) TYPE c .
DATA gv_outer_index LIKE sy-index .
DATA gv_intex(2) TYPE c .
DATA gv_line_cntr TYPE i . "line counter
DATA gv_linno TYPE i . "line number
DATA gv_colno TYPE i . "column number
DATA gv_value TYPE i . "data
PARAMETERS: p_sheets TYPE i .
*Step 2 Initiate the do-loop and OLE automation base objects.
*Code Part C.2 Looping and initializing, adding new worksheets
START-OF-SELECTION .
DO p_sheets TIMES .
*--Forming sheet name
gv_intex = sy-index .
gv_outer_index = sy-index .
CONCATENATE 'Excel Sheet #' gv_intex INTO gv_sheet_name .
*--For the first loop, Excel is initiated and one new sheet is added
IF sy-index = 1 .
CREATE OBJECT gs_excel 'EXCEL.APPLICATION' .
SET PROPERTY OF gs_excel 'Visible' = 1 .
GET PROPERTY OF gs_excel 'Workbooks' = gs_wbooklist .
GET PROPERTY OF gs_wbooklist 'Application' = gs_application .
SET PROPERTY OF gs_application 'SheetsInNewWorkbook' = 1 .
CALL METHOD OF gs_wbooklist 'Add' = gs_wbook .
GET PROPERTY OF gs_application 'ActiveSheet' = gs_activesheet .
SET PROPERTY OF gs_activesheet 'Name' = gv_sheet_name .
*--For the rest of loops, other sheets are added
ELSE .
GET PROPERTY OF gs_wbook 'Sheets' = gs_sheets .
CALL METHOD OF gs_sheets 'Add' = gs_newsheet .
SET PROPERTY OF gs_newsheet 'Name' = gv_sheet_name .
ENDIF .
gv_line_cntr = 1 . "line counter
*Step3 Write the title and format it.
*--Title
*--Selecting cell area to be merged.
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF gs_excel 'Cells' = gs_cell2
EXPORTING
#1 = 1
#2 = 4.
CALL METHOD OF gs_excel 'Range' = gs_cells
EXPORTING
#1 = gs_cell1
#2 = gs_cell2.
CALL METHOD OF gs_cells 'Select' .
*--Merging
CALL METHOD OF gs_cells 'Merge' .
*--Setting title data
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = gv_line_cntr
#2 = 1.
SET PROPERTY OF gs_cell1 'Value' = 'TITLE' .
*Code Part C.3 Writing and formatting the title
*--Formatting the title
GET PROPERTY OF gs_cell1 'Font' = gs_font .
SET PROPERTY OF gs_font 'Underline' = 2 .
SET PROPERTY OF gs_font 'Bold' = 1 .
SET PROPERTY OF gs_cell1 'HorizontalAlignment' = -4108 .
GET PROPERTY OF gs_cell1 'Interior' = gs_interior .
SET PROPERTY OF gs_interior 'ColorIndex' = 15 .
SET PROPERTY OF gs_interior 'Pattern' = -4124 .
SET PROPERTY OF gs_interior 'PatternColorIndex' = -4105 .
*Step 4 Write some additional data for the title area and format them.
gv_line_cntr = gv_line_cntr + 1 .
*--Writing some additional data for the title
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = gv_line_cntr
#2 = 1.
SET PROPERTY OF gs_cell1 'Value' = 'Sheet No' .
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = gv_line_cntr
#2 = 5.
SET PROPERTY OF gs_cell1 'Value' = ':' .
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = gv_line_cntr
#2 = 6.
SET PROPERTY OF gs_cell1 'Value' = gv_intex .
*--Formatting the area of additional data 1
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF gs_excel 'Cells' = gs_cell2
EXPORTING
#1 = gv_line_cntr
#2 = 5.
CALL METHOD OF gs_excel 'Range' = gs_cells
EXPORTING
#1 = gs_cell1
#2 = gs_cell2.
CALL METHOD OF gs_cells 'Select' .
GET PROPERTY OF gs_cells 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .
*--Formatting the area of additional data 2
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = 1
#2 = 5.
CALL METHOD OF gs_excel 'Cells' = gs_cell2
EXPORTING
#1 = gv_line_cntr
#2 = 5.
CALL METHOD OF gs_excel 'Range' = gs_cells
EXPORTING
#1 = gs_cell1
#2 = gs_cell2.
CALL METHOD OF gs_cells 'Select' .
GET PROPERTY OF gs_cells 'Columns' = gs_columns .
CALL METHOD OF gs_columns 'AutoFit' .
*--Bordering title data area
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = 1
#2 = 1.
CALL METHOD OF gs_excel 'Cells' = gs_cell2
EXPORTING
#1 = gv_line_cntr
#2 = 6.
CALL METHOD OF gs_excel 'Range' = gs_cells
EXPORTING
#1 = gs_cell1
#2 = gs_cell2.
CALL METHOD OF gs_cells 'Select' .
CALL METHOD OF gs_cells 'BorderAround'
EXPORTING
#1 = 1 "continuous line
#2 = 4. "thick
*Code Part C.4 Some additional writing to the title area, formatting
*and bordering around the title area
*Step 5 Put axis labels to the data area.
*Code Part C.5 Axis Labels
*--Putting axis labels
gv_colno = 2 .
gv_line_cntr = gv_line_cntr + 5 .
gv_linno = gv_line_cntr - 1 .
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = gv_linno
#2 = 1.
SET PROPERTY OF gs_cell1 'Value' = 'X' .
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = gv_line_cntr
#2 = 1.
SET PROPERTY OF gs_cell1 'Value' = 'Y' .
*Step 6 Generate some data.
*Code Part C.6 Generating Data
*--Generating some data
DO 3 TIMES .
gv_value = gv_outer_index * sy-index * 10 .
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = gv_linno
#2 = gv_colno.
SET PROPERTY OF gs_cell1 'Value' = sy-index .
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = gv_line_cntr
#2 = gv_colno.
SET PROPERTY OF gs_cell1 'Value' = gv_value .
gv_colno = gv_colno + 1 .
ENDDO .
*Step 7 Set source data area for the chart.
*Code Part C.7 Setting source data area for the chart
*--Source data area
gv_colno = gv_colno - 1 .
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = gv_linno
#2 = 1.
CALL METHOD OF gs_excel 'Cells' = gs_cell2
EXPORTING
#1 = gv_line_cntr
#2 = gv_colno.
CALL METHOD OF gs_excel 'Range' = gs_cells
EXPORTING
#1 = gs_cell1
#2 = gs_cell2.
CALL METHOD OF gs_cells 'Select' .
*Step8 Draw the chart
*Code Part C.8 Draw the chart
GET PROPERTY OF gs_application 'Charts' = gs_charts .
CALL METHOD OF gs_charts 'Add' = gs_chart .
CALL METHOD OF gs_chart 'Activate' .
SET PROPERTY OF gs_chart 'ChartType' = '51' . "Vertical bar graph
CALL METHOD OF gs_chart 'SetSourceData'
EXPORTING
#1 = gs_cells
#2 = 1.
SET PROPERTY OF gs_chart 'HasTitle' = 1 .
GET PROPERTY OF gs_chart 'ChartTitle' = gs_charttitle .
GET PROPERTY OF gs_charttitle 'Characters' = gs_charttitlechar .
SET PROPERTY OF gs_charttitlechar 'Text' = 'Sample Graph' .
*Step 9 Locate the chart onto the current worksheet.
*Code Part C.9 Locating the chart onto the current worksheet
*--Locate the chart onto the current worksheet
*--Activate current sheet
CALL METHOD OF gs_excel 'WorkSheets' = gs_activesheet
EXPORTING
#1 = gv_sheet_name.
CALL METHOD OF gs_activesheet 'Activate' .
CALL METHOD OF gs_chart 'Location'
EXPORTING
#1 = 2
#2 = gv_sheet_name.
*Step 10 Reposition the chart to a proper place and finish the do-loop.
*Code Part C.10 Repositioning the chart to a proper place and end of
*the do-loop counting sheet number
*--Reposition the chart on the worksheet (cut&paste)
CALL METHOD OF gs_activesheet 'ChartObjects' = gs_chartobjects .
CALL METHOD OF gs_chartobjects 'Select' .
CALL METHOD OF gs_chartobjects 'Cut' .
*--Select new area
gv_line_cntr = gv_line_cntr + 2 .
CALL METHOD OF gs_excel 'Cells' = gs_cell1
EXPORTING
#1 = gv_line_cntr
#2 = 1.
CALL METHOD OF gs_excel 'Cells' = gs_cell2
EXPORTING
#1 = gv_line_cntr
#2 = 1.
CALL METHOD OF gs_excel 'Range' = gs_cells
EXPORTING
#1 = gs_cell1
#2 = gs_cell2.
CALL METHOD OF gs_cells 'Select' .
CALL METHOD OF gs_activesheet 'Paste' .
ENDDO .
*Step 11 Free OLE objects to deallocate memory.
*Code Part C.11 Deallocating the memory
*--Deallocating memory
FREE: gs_excel, gs_wbooklist, gs_application, gs_wbook,
gs_activesheet,gs_sheets, gs_newsheet, gs_cell1,
gs_cell2, gs_cells, gs_range, gs_font, gs_interior,
gs_columns, gs_charts, gs_chart, gs_charttitle,
gs_charttitlechar, gs_chartobjects . -
GPF and OLE Automation with Word6
Has anyone else had a problem with GPFs when trying to use Word6 as an OLE
Automation Server? Whenever our users try to open Word6 from the
application they get a GPF in QQKN.DLL at 000C:955C. What does the QQKN.DLL
do?
Any ideas?
- Scott Splavec - MIS 8
Business Analyst
Kirke-Van Orsdel, Inc.
1776 West Lakes Parkway
West Des Moines, IA 50398
(515) 248-6472
eMail: kvi!kvidm01![email protected]Hi Aurang
You can call almost all methods using OLE. What is required is to know how to interpret a script to ABAP OLE call. This is explained in the tutorial<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1d54348-0601-0010-3e98-bd2a2dcd9e6c">"An Easy Reference For OLE Automation"</a>
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a> -
OLE Automation to Excel problem
Hello All,
In a report program I have used the OLE2 automation to download data into Excel. But it's not functioning. Its doing nothing. Could you tell me do I have to have any authorizations to use this? Otherwise what could be the problem?
Plz advise.
Thanks a lot.Thnx Rich.
Here's the code:
<b>REPORT ZMR_MAX_PERIOD.
*-- Tables----
tables: mara, "General Material Data
marc, "Plant Data for Material
makt. "Material Descriptions
*-- Data of OLE
include ole2incl.
data: GS_EXCEL type ole2_object,
GS_BOOKS type ole2_object,
GS_WBOOK type ole2_object,
GS_SHEET type ole2_object,
GS_PAGE type ole2_object,
GS_RANGE type ole2_object,
GS_FONT type ole2_object,
GS_COLS type ole2_object,
GS_CELL type ole2_object.
*-- Variables----
*-- Offsets for output columns
data: w_wid01 type i,
w_wid02 type i,
w_wid03 type i,
w_wid04 type i,
w_wid05 type i,
w_wid06 type i,
w_wid07 type i,
w_wid08 type i,
w_wid09 type i,
w_wid10 type i,
w_wid11 type i,
w_wid12 type i,
w_wid13 type i,
w_wid14 type i,
w_wid15 type i,
w_wid16 type i,
w_wid17 type i,
w_color(1). "for background color
*-- Constants----
*-- Column widths for report output
constants: c_space type i value 0,
c_wid01 type i value 1,
c_wid02 type i value 6,
c_wid03 type i value 1,
c_wid04 type i value 15,
c_wid05 type i value 1,
c_wid06 type i value 19,
c_wid07 type i value 1,
c_wid08 type i value 42,
c_wid09 type i value 1,
c_wid10 type i value 21,
c_wid11 type i value 1,
c_wid12 type i value 10,
c_wid13 type i value 1,
c_wid14 type i value 12,
c_wid15 type i value 1,
c_wid16 type i value 17,
c_wid17 type i value 1.
*-- Internal tables----
*-- Internal table for material data
data: begin of i_material occurs 0,
matnr like mara-matnr,
mtart like mara-mtart,
aenam like mara-aenam,
laeda like mara-laeda,
werks like marc-werks,
maxlz like marc-maxlz,
lzeih like marc-lzeih,
maktx like makt-maktx,
end of i_material.
*-- Internal table for output
data: begin of i_output occurs 0,
werks like marc-werks, "Plant
mtart like mara-mtart, "Material type
matnr like mara-matnr, "Material number
maktx like makt-maktx, "Material description
maxlz like marc-maxlz, "Maximum storage period
lzeih like marc-lzeih, "Unit for maximum storage period
aenam like mara-aenam, "User changed the object
laeda like mara-laeda, "Last changed on
end of i_output.
SELECTION-SCREEN DEFINITION
*-- Data Selection
selection-screen begin of block b1 with frame title title1.
select-options: s_matnr for mara-matnr,
s_werks for marc-werks,
s_lgpro for marc-lgpro,
s_mtart for mara-mtart.
selection-screen end of block b1.
AT SELECTION-SCREEN VALIDATIONS
at selection-screen.
*--Check Plant is entered
if s_werks is initial.
message e009(zm) with 'please enter plant'.
endif.
INITIALIZATION
initialization.
*-- initialize text fields for selection-screen
title1 = 'Material Data'.
title2 = 'File locations'.
perform assign_column_widths.
START-OF-SELECTION (Required in 4.6)
start-of-selection.
set pf-status 'MAIN'.
*-- Perform get data
perform get_data.
*-- Populate data into output tab
perform populate_data.
*-- Write output list
perform write_output.
END-OF-SELECTION
TOP-OF-PAGE
TOP OF PAGE AT LINE SELECTION
AT LINE SELECTION
AT USER COMMAND
at user-command.
*-- Download to Excel
case sy-ucomm.
when 'EXCEL'.
perform download_to_excel.
endcase.
--S-U-B-R-O-U-T-I-N-E-S--
FORM SET_BACKGROND_COLOR
Set background color for list output
form set_background_color.
if w_color = 1.
FORMAT INTENSIFIED OFF COLOR 2.
clear w_color.
else.
FORMAT INTENSIFIED ON COLOR 2.
w_color = 1.
endif.
endform. "set_background_color
FORM GET_DATA
Get material data
form get_data.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
TEXT = 'reading material data... '
select mara~matnr
mara~mtart
mara~aenam
mara~laeda
marc~werks
marc~maxlz
marc~lzeih
makt~maktx
into table i_material
from mara
join marc
on maramatnr = marcmatnr
join makt
on marcmatnr = maktmatnr
where mara~matnr IN s_matnr
and marc~werks IN s_werks
and marc~lgpro IN s_lgpro
and mara~mtart IN s_mtart.
sort i_material by matnr.
endform. "get_data
FORM POPULATE_DATA
Populate data for output
form populate_data.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
TEXT = 'Processing data... '
loop at i_material.
move i_material-werks to i_output-werks.
move i_material-mtart to i_output-mtart.
move i_material-matnr to i_output-matnr.
move i_material-maktx to i_output-maktx.
move i_material-maxlz to i_output-maxlz.
move i_material-lzeih to i_output-lzeih.
move i_material-aenam to i_output-aenam.
move i_material-laeda to i_output-laeda.
append i_output.
clear i_output.
endloop.
sort i_output by matnr.
endform. "populate_data
FORM WRITE_COLUMN_HEADINGS
Write column headings for output
form write_column_headings.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
TEXT = 'Writing output... '
if i_output[] is initial.
message i000.
exit.
endif.
*-- Write column headings
skip.
uline.
FORMAT COLOR 1 ON.
write: at /w_wid01 sy-vline.
write: at /w_wid02(c_wid02) 'Plant' CENTERED,
at w_wid03(c_wid03) SY-VLINE,
at w_wid04(c_wid04) 'Material Type' CENTERED,
at w_wid05(c_wid05) SY-VLINE,
at w_wid06(c_wid06) 'Material Number' CENTERED,
at w_wid07(c_wid07) SY-VLINE,
at w_wid08(c_wid08) 'Material Description' CENTERED,
at w_wid09(c_wid09) SY-VLINE,
at w_wid10(c_wid10) 'Max. Storage Period' CENTERED,
at w_wid11(c_wid11) SY-VLINE,
at w_wid12(c_wid12) 'Time Unit' CENTERED,
at w_wid13(c_wid13) SY-VLINE,
at w_wid14(c_wid14) 'Changed By' CENTERED,
at w_wid15(c_wid15) SY-VLINE,
at w_wid16(c_wid16) 'Last Changed On' CENTERED,
at w_wid17(c_wid17) SY-VLINE.
FORMAT COLOR 1 OFF.
uline.
endform. "write_column_headings
FORM WRITE_OUTPUT
Write list output
form write_output.
loop at i_output.
perform set_background_color.
write: at /w_wid01(c_wid01) SY-VLINE,
at w_wid02(c_wid02) i_output-werks,
at w_wid03(c_wid03) SY-VLINE,
at w_wid04(c_wid04) i_output-mtart,
at w_wid05(c_wid05) SY-VLINE,
at w_wid06(c_wid06) i_output-matnr,
at w_wid07(c_wid07) SY-VLINE,
at w_wid08(c_wid08) i_output-maktx,
at w_wid09(c_wid09) SY-VLINE,
at w_wid10(c_wid10) i_output-maxlz,
at w_wid11(c_wid11) SY-VLINE,
at w_wid12(c_wid12) i_output-lzeih,
at w_wid13(c_wid13) SY-VLINE,
at w_wid14(c_wid14) i_output-aenam,
at w_wid15(c_wid15) SY-VLINE,
at w_wid16(c_wid16) i_output-laeda,
at w_wid17(c_wid17) SY-VLINE.
endloop.
endform. "write_output
FORM DOWNLOAD_TO_EXCEL
Download report data to excel spreadsheet
form download_to_excel.
data: row type i value '2'.
*-- Create Excel spreadsheet
create object GS_EXCEL 'EXCEL.APPLICATION'.
if sy-subrc <> 0.
message e002(sy) with sy-msgli.
endif.
call method of GS_EXCEL 'WORKBOOKS' = GS_BOOKS.
call method of GS_BOOKS 'ADD' = GS_WBOOK.
*-- Add column headers
perform fill_cell using 1 1 'Plant'.
perform fill_cell using 1 2 'Material Type'.
perform fill_cell using 1 3 'Material Number'.
perform fill_cell using 1 4 'Material Description'.
perform fill_cell using 1 5 'Max Storage'.
perform fill_cell using 1 6 'Time Unit'.
perform fill_cell using 1 7 'Changed By'.
perform fill_cell using 1 8 'Last Changed On'.
loop at i_output.
perform fill_cell using row 1 i_output-werks.
perform fill_cell using row 2 i_output-mtart.
perform fill_cell using row 3 i_output-matnr.
perform fill_cell using row 4 i_output-maktx.
perform fill_cell using row 5 i_output-maxlz.
perform fill_cell using row 6 i_output-lzeih.
perform fill_cell using row 7 i_output-aenam.
perform fill_cell using row 8 i_output-laeda.
row = row + 1.
endloop.
*-- Set name of spreadsheet
call method of GS_EXCEL 'ACTIVESHEET' = GS_SHEET.
set property of GS_SHEET 'NAME' = 'Max Storage Period'.
*-- Set orientaion to landscape.
call method of GS_SHEET 'PAGESETUP' = GS_PAGE.
set property of GS_PAGE 'ORIENTATION' = 2.
free object GS_PAGE.
*-- Make column headers bold and centered
call method of GS_SHEET 'RANGE' = GS_RANGE exporting #1 = 'A1:Z1'.
set property of GS_RANGE 'HORIZONTALALIGNMENT' = 3.
call method of GS_RANGE 'FONT' = GS_FONT.
set property of GS_FONT 'BOLD' = 1.
free object GS_RANGE.
free object GS_FONT.
*-- Set column widths to autofit
call method of GS_SHEET 'RANGE' = GS_RANGE exporting #1 = 'A1:Z1'.
set property of GS_RANGE 'COLUMNS' = GS_COLS.
call method of GS_COLS 'AUTOFIT'.
*-- Display spreadsheet
set property of GS_EXCEL 'VISIBLE' = 1.
*-- Free OLE objects
free object GS_EXCEL.
free object GS_BOOKS.
free object GS_WBOOK.
free object GS_SHEET.
free object GS_RANGE.
free object GS_COLS.
free object GS_CELL.
endform. "download_to_excel
FORM FILL_CELL
Add report fields to Excel sheet
form fill_cell using row col value.
call method of GS_EXCEL 'CELLS' = GS_CELL exporting #1 = row
#2 = col.
set property of GS_CELL 'VALUE' = VALUE.
free object GS_CELL.
endform.
----</b> -
I had forms developped with forms 4.5
I did things like that :
-- open OLE object in Word
Forms_OLE.Activate_Server(wordItem);
application :=OLE2.CREATE_OBJ('Word.Basic');
Forms_OLE.Exec_Verb(wordItem, 1);
-- insert text in Word document
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, text);
OLE2.Invoke(application, 'Insert', args);
OLE2.Destroy_Arglist(args);
-- print document
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 0);
OLE2.Invoke(application, 'FilePrint', args);
OLE2.Destroy_Arglist(args);
-- exit Word
OLE2.Invoke(application, 'FileExit');
-- release server
if (Forms_OLE.Server_Active(item_id)) then
Forms_OLE.Close_Server(item_id);
end if;
With Form 6.0, Invoke method seems not to work anymore.
I suppose I have to use
Init_OleArgs(2);
Add_OleArg('insertText', VT_BSTR);
Add_OleArg('my text', VT_BSTR);
Call_Ole(itemName, ?);
Is it that and what should be the 2nd parameter of Call_Ole method ?
Thanks
Nico
nullWith Forte Release2 supporting only OLE callout, you can use DDE
to pass data; but with Release 3 which supports OLE callin , you
should be able to pass data both ways.
- Arvind
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Arvind Kumar Krishnaswamy
Digital/Forte Software Products Group
Digital Equipment Corporation ______________________
1800,Harrison Street,Suite 1700, | | | | | | | |
Oakland.CA 94612 USA |d |i |g |i |t |a |l |
| | | | | | | |
Tel : 510-251-6537 ----------------------
Fax : 510-251-6531
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -
Automation with Excel question
Hello all,
I'm very new to the use of automator and I'm trying to see if this software can help in what I'm trying to do before I find out later on that it can't.
This is what I'm attempting to accomplish, I have a product that I create in excel I later take that product and input it into a different excelt product where specific information goes into certain blocks.
What I'm hoping to figure out is having automator take the information from certain cells in product 1 and copy/move or whatever it into the other workbook into specific cells.... Then continue down the list until complete.
Any information on this will help a ton.Yes basically it could just be copy and pasted...
Workbook 1 has the information, A1 through A12 lets say has 1 block on information
B1 - B12 a different set
I would like something that would go through each set maybe for a set amount of likes and put the information into the 2nd workbook in specific areas.
This would create about 20-30 different sheet entries making creating this product on a daily basis a whole lot easier since it's printed out and written by hand at the moment.
Any suggestions as to what I can use to help these people accomplish this task faster and easier would be a great success. -
PICTURE MTHOD in OLE AUTOMATION
Hi,
Can anyone send me information for the "picture" method using OLE AUTOMATION for Excel Objects.
Thanks and Regards
AKhi
good
go through the following links i hope this will help you to solve your problem.
Re: OLE Automation with Excel
http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm
http://sap.ittoolbox.com/code/archives.asp?d=3027&a=s&i=10
thanks
mrutyun -
Auteur : Corinne Ribeyre-F085785 à _CARPO04
I need help with OLE Automation implementation (Excel,
CrystalReport,Word ...)
I generate Excel project with OleGen but no documentation exist for
this project. So I made severals tests (with Excel).
I can do (see examples):
- open a file
- open Excel Application
- open WorkBook, WoorkSheet
- Write and Read a Cell (but I am not sure it's the more efficient
method to do this)
- run a macro with parameters
But, I CAN'T do:
- run a command with parameters like PivotTableWizard (tableau croise
dynamique)
Does a Documentation exist about Forte project generated by Olegen
Tool (Excel..) ?
Does a Documentation exist about Forte/Crystal Report ?
Thank You for all answers and examples,
Corinne
Examples
-- Open Excel
theApplication : Excel . Application = New;
theApplication . CreateUsingProgID(NX('excel.application'));
--- Excel Visible /not visible
theApplication . Visible = VariantBoolean(Value = False);
-- Get all WorkBooks of Excel Application
theWorkBooks : Excel . WorkBooks = New;
theWorkBooks . SetDispatchObject(theApplication . Workbooks());
-- Open File.xls (added with previous Application)
theWorkBooks . Open (VariantString(Value = 'C:\\temp\\File.xls'));
-- Link file with a WorkBook
aWorkBook : Excel . WorkBook = New;
aWorkBook . SetDispatchObject(theApplication .
Workbooks(VariantString(value='File.xls')));
-- Link a Folder (Sheet1) from File with WorkSheet
aWorksheet : Excel . Worksheet = New;
aWorksheet . SetDispatchObject(aWorkBook .
Worksheets(VariantString(value='Sheet1')));
aRange : Excel . Range = New;
-- Fill Cell (1,1) with 'Article'
TitreArt : VariantString = VariantString(Value = 'Article');
aRange . SetDispatchObject(aWorksheet . Cells(VariantInteger(Value =
1), VariantInteger(Value = 1)));
aRange . Value = titreArt;
-- Fill Cell (1,2) with 'Date'
TitreDate : VariantString = VariantString(Value = 'Date');
aRange . SetDispatchObject(aWorksheet . Cells(VariantInteger(Value =
1), VariantInteger(Value = 2)));
aRange . Value = TitreDate;
-- Run a Macro
theApplication . Run(VariantString(Value = NX('MacroName')),
VariantInteger(Value = 65),
VariantInteger(Value = 7));
-- Page Setup
-- Link a Folder (Sheet2) from File with WorkSheet
aWorksheet . SetDispatchObject(aWorkBook .
Worksheets(VariantString(value='Sheet2')));
aPageSetup : Excel . PageSetUp = New;
aPageSetup . SetDispatchObject(aWorksheet.PageSetup);
aPageSetup . PrintTitleRows = VariantString (Value = '');
aPageSetup . PrintTitleColumns = VariantString (Value = '');
aPageSetup . LeftHeader = VariantString (Value = 'MICKEY');
aPageSetup . CenterHeader = VariantString (Value = 'MOUSE');
aPageSetup . RightHeader = VariantString (Value = '&J &H'); --
Attention J H en Excel Français; D T en Anglais
aPageSetup . LeftFooter = VariantString (Value = '');
aPageSetup . CenterFooter = VariantString (Value = 'DISNEYLAND
PARIS');
aPageSetup . RightFooter = VariantString (Value = '&P / &T');
aPageSetup . LeftMargin = VariantInteger(Value = 1);
aPageSetup . RightMargin = VariantInteger(Value = 1);
aPageSetup . TopMargin = VariantInteger(Value = 1);
aPageSetup . BottomMargin = VariantInteger(Value = 1);
aPageSetup . HeaderMargin = VariantDouble(Value = 0.5);
aPageSetup . FooterMargin = VariantDouble(Value = 0.5);
aPageSetup . PrintHeadings = VariantBoolean(Value = False);
aPageSetup . PrintGridlines = VariantBoolean(Value = False);
aPageSetup . PrintNotes = VariantBoolean(Value = False);
aPageSetup . CenterHorizontally = VariantBoolean(Value = True);
aPageSetup . CenterVertically = VariantBoolean(Value = True);
aPageSetup . Orientation = VariantInteger(Value = 2); --
(1:xlPortrait, 2:xlLandscape)
aPageSetup . Draft = VariantBoolean(Value = False);
aPageSetup . PaperSize = VariantInteger(Value = 9);
-- (8: xlPaperA3, 9: xlPaperA4)
aPageSetup . FirstPageNumber = VariantInteger(Value = -4105);
-- xlAutomatic
aPageSetup . Order = VariantInteger(Value = 1);
-- xlDownThenOver
aPageSetup . BlackAndWhite = VariantBoolean(Value = True);
aPageSetup . Zoom = VariantBoolean(Value = False);
aPageSetup . FitToPagesWide = VariantInteger(Value = 1);
aPageSetup . FitToPagesTall = VariantInteger(Value = 1);
-- Save File
aFilename : VariantString = VariantString(Value =
NX('C:/Temp/Essai.xls'));
aWorkBook . SaveAS(FileName = aFilename);
-- Print File
PrintOptions : PrintOptionsDesc;
PrintOptions = Self . Window . WindowSystem . DefaultPrintOptions .
Clone (Deep = True);
If (self.Window.PrintDialog (PrintOptions= PrintOptions,
ShowSetupDialog = TRUE,
ShowJobDialog = FALSE) = BV_OK) Then
aWorksheet . PrintOut();
End If;
-- Unlink
aWorkBook . RunAutoMacros(VariantInteger(Value = 2)); --xlAutoFermer
-- Cf doc VBA
aWorkBook . Close(variantboolean (Value = False));
TheApplication . Quit();
To unsubscribe, email '[email protected]' with
'unsubscribe forte-users' as the body of the message.
Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>Hi all, forget this silly question...
I studied a little bit and learned how to handle OLEs properly...
Many thanks -
Discoverer 3i through ole automation
Do you know,
where to find information about using ole automation with Discoverer 3i.<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by jr vasquez ([email protected]):
Also, is there a method of bypassing the authentication and passing arguments into Discoverer rather than having to login? If I am maintaining a userlist in another application can I not use that authentication method and pass that into Discoverer?<HR></BLOCKQUOTE>
For the Client server application, You can bypass login by passing parameters to the application. This is documented in the Discoverer User's Guide, Under Advanced Features, Using Command Line Options.
Discoverer Viewer and Discoverer Plus (java) also permit this through the urls used to launch the application. This is also documented.
Documentation for Discoverer OLE Automation may be found via Oracle Metalink. Type in 'Discoverer, OLE' in the search window and a technical bulletin, "Programmatic Control of Discoverer 3.1", will be returned. -
OLE Automation: EXCEL not starting
I am using OLE Automation to download table data to a spreasheet. I got everything working, and EXCEL starts and sheets get created and populated with the data. Everything appears fine. When I had my co-workers test it, EXCEL doesn't start up for them, and nothing happens. What could this be?
I've tried having my co-workers open EXCEL first, and it doesn't matter. They still get nothing. Mine, however, starts when I don't have EXCEL open. If I do have it open, it brings up a new window of EXCEL.
-
Excel Automation with Interop - Windows Service - Microsoft Excel cannot access the file
I have a windows console application, which automates Excel. In our scenario the application gets called from a Windows Service. If the console app is executed directly everything works fine. If the console app is executed through the Win Service, we get
the following error when trying to open the excel file:
Unhandled exception Occured : 'Microsoft Excel cannot access the file 'bla.xls'. There are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook.'.'
The code snippet used to open the file:
xlApp = new Application();xlApp.Visible = false;xlApp.UserControl = false;xlApp.Application.ScreenUpdating = false;xlApp.DisplayAlerts = false;xlWorkbook = xlApp.Workbooks.Open( Filename: filePath, UpdateLinks: 2, IgnoreReadOnlyRecommended: true, Editable: false);
The console app and windows service are running on a Win Server 2008 64-bit OS with Excel 2013 32-bit installed. The service is running with a special user account, which has all the right permissions on accessed files and folders. The excel process is also
started with the same account (I cheched that one).
I already tried to do the following, but to no avail:
Run excel.exe /automation -> worked fine
Created the folders and also gave full control to the account under which the service is run (even gave full control to Everyone)
C:\Windows\SysWOW64\config\systemprofile\Desktop
C:\Windows\System32\config\systemprofile\Desktop
Configured DCOM
Excel Application -> Identity -> Specific user account
Excel Application -> Identity -> Interactive User
Excel Application -> Security -> Launch permissions -> Everyone full control
Several combinations of the above
So I really am stuck with this problem right now. Any input on this is appreciated.I have a windows console application, which automates Excel. In our scenario the application gets called from a Windows Service. If the console app is executed directly everything works fine. If the console app is executed through the Win Service, we get
the following error when trying to open the excel file
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office
may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side.
If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
You can read more about that in the
Considerations for server-side Automation of Office article. -
OLE Automation for Word. EditGoto with Word 97
I found a solution. Instead EditGoto, use WW7_EditGoto.
Example:
.- A Word Template whith two bookmarks
(Texto1, Tabla1). A normal bookmark
(Texto1) and a bookmark into a Word
Table (Tabla1).
In the Word Table, is posible change
cell o create a new row with the same
command (NextCell).
The word table has two columns an two
rows.
The first row is the Header.
The second row the first column contain
a bookmark (Tabla1).
.- A Form whit two blocks:
First block with two items:
nombre_doc
texto1
Secod Block (multirecord) whit two items
col1
col2
with a When-Button-Pressed:
DECLARE
application OLE2.OBJ_TYPE;
args OLE2.LIST_TYPE;
BEGIN
-- Start WordBasic and make Word visible
application:=OLE2.CREATE_OBJ('Word.Basic');
OLE2.INVOKE(application, 'AppShow');
-- Open a Word document
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args,'Plantilla.dot');
OLE2.INVOKE(application, 'FileOpen', args);
OLE2.DESTROY_ARGLIST(args);
-- Put Text in the first bookmark
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args,'Texto1');
OLE2.INVOKE(application, 'WW7_EditGoto', args);
OLE2.DESTROY_ARGLIST(args);
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args,:Texto1);
OLE2.INVOKE(application, 'Insert', args);
OLE2.DESTROY_ARGLIST(args);
-- Send data from Multirecord Block to Word Table
GO_BLOCK('MULTI');
FIRST_RECORD;
IF :SYSTEM.RECORD_STATUS != 'NEW' THEN
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args,'Tabla1');
OLE2.INVOKE(application, 'WW7_EditGoto', args);
OLE2.DESTROY_ARGLIST(args);
LOOP
IF :col1 IS NOT NULL THEN
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args,:col1);
OLE2.INVOKE(application, 'Insert', args);
OLE2.DESTROY_ARGLIST(args);
END IF;
OLE2.INVOKE(application, 'NextCell');
IF :col2 IS NOT NULL THEN
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args,:col2);
OLE2.INVOKE(application, 'Insert', args);
OLE2.DESTROY_ARGLIST(args);
END IF;
EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
NEXT_RECORD;
OLE2.INVOKE(application, 'NextCell');
END LOOP;
-- Save a Word document
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args,:nombre_doc);
OLE2.INVOKE(application, 'FileSaveas', args);
OLE2.DESTROY_ARGLIST(args);
--Release the OLE object
OLE2.RELEASE_OBJ(application);
END;
Sorry by the sintax, but i don't speak English.
I hope it solves this problem.Hello,
I am also trying to use the OLE2 package for OLE Automation. But
difference being that I am not using Word but am using an
invisible control for Mail services, using the objects
MAPISession, MAPImessages. If anyone out there had already done
this do please give me a code snippet.
Thanx in advance
Anup Mistry,
Programmer/Analyst,
IIS,Inc
Vasile (guest) wrote:
: Hi Daniel,
: I used OLE with forms 5 ,but now it work without problems in
: forms 6, too.
: A procedure that save doc. look like that:
: procedure filesaveas (fname in varchar2) is
: arglist ole2.list_type;
: begin
: arglist := ole2.create_arglist;
: ole2.add_arg (arglist, fname);
: ole2.invoke (obj_hnd, 'filesaveas', arglist);
: ole2.destroy_arglist (arglist);
: end;
: I hope this help you.
: Vasile
: Daniel Fox (guest) wrote:
: : I am using Forms 6.0
: : Can anyone help with OLE automation using OLE2.
: : I can open Word, document stored in long raw, even insert
data
: : from other form field into the Word Document (only at the
: : beginning of the Document, though).
: : All the File commands, such as FileSaveAs, EditGoTo, etc..
: don't
: : work. They are simply ignored - no error messages, nothing.
: : Does anyone use Word Automation through Forms 6.0?
: : Please, HELP....
: : Thanks in advance,
: : Desperate Daniel.
null -
Problem with Excel automation refnum
While presenting ActiveX functions to students, I ran into an unexpected problem : only half of the PCs were able to work with Excel after the initial basic steps :
place an automation refnum on the front panel
right-click the automation refnum, then select ActiveX class, then select browse
find Microsoft Excel objects library and select application
connect an Automation open function
etc...
What happened is that an error 3005 (Automation Open: Object specified is not creatable in ... ) was generated on half the machines, while everything was running smoothly on the others.
A workaround was to grab a working automation refnum control from the examples shipped with LabVIEW. The icon appears different and has a black arrow instead of the purple one got from the refnums palette. But even with this refnum, the problem could be reproduced when the activeX class was changed forth and back !
All the systems (Windows XP- LV 8.2) and machines were identical, configured initially from the same disk image.
Do you an idea of what's going on there ? Do you know where I can get the black-arrowed automation refnum ?
Message Edité par chilly charly le 12-08-2006 05:32 AM
Chilly Charly (aka CC)
E-List Master - Kudos glutton - Press the yellow button on the left...
Attachments:
Example_BD.png 3 KBBump...
Chilly Charly (aka CC)
E-List Master - Kudos glutton - Press the yellow button on the left...
Maybe you are looking for
-
How to bind data (from database) to the Dictionary structure in Web Dynpro
Hi, I am getting Hashtable object from the database related classes and I want to bind this data to the Dictionary field in Web Dynpro. So, I can bind this Dictionary field type to the Context variable. Please let me know the detailed procedure. Than
-
Why is the 'mac pro' missing from the mac store?
why is the 'mac pro' missing from the mac store? I always enjoyed speccing up machines that i will one day upgrade to.
-
IPhone 5 won't update to iOS 8
Hey there I seem to be having this software update with my iPhone 5 software. Previously when iOS 7 had come out... I had tried to update my phones software by using iTunes and it would go 3/4 way through and a message would come up saying that the s
-
How to transport mapping format for ELM ????
Hi All, I want to know how to transport the Mapping Format that we create for external list management (ELM). I clicked on the Customizing Transport link given in toolbar. But that doesnt seem to create any subtask. Is there any other procedure
-
How to adjust animation start point for text presets
Hi All, I am applying text animation from standard presets - Multi-line group. The presetI am using is production.ffx. it works fine, but I cannot figure out how to adjust its start time. The animation starts in about 3 sec, but I need to trigger it