Focal Point
[CLOSED] Running a macro using web focus code (Excel 2k )

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2861070712

March 08, 2007, 05:45 AM
Code Digger
[CLOSED] Running a macro using web focus code (Excel 2k )
Is there any way of running a macro through webfocus code when generating reports in excel format?
I have created a .mht file which includes a statement to directly print the report output: "ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True" and this .mht file is referred to in my ON TABLE PCHOLD statement. But the result is: when i run my report, i do get the output in excel format and then when i go to Tools->Macro->Macros and then run the macro(the macro does appear), the output is getting printed. Is there any way such that when my excel output gets generated, at the same time, the macro is run ?

This message has been edited. Last edited by: Kerry,
March 08, 2007, 01:18 PM
Tony A
CD,

You will need to identify a suitable event to use. Not sure what it might be. Have you tried an Excel forum?



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
March 08, 2007, 02:04 PM
Dennis_V
CD,

Are you wanting your .mht to auto-run the macro when the report opens in Excel so that it brings up the print dialogue window to print the spreadsheet?

Dennis


Local: AppStudio 8.2.03 - Win7 - Tomcat Server: WebFOCUS 8.2.03 - Windows 2008 R2 Enterprise on VMWare 2 CPU, 3.2GHz, 4GB of RAM Output Formats: HTML, Excel, PDF, PPT, Active Reports
March 09, 2007, 12:02 AM
Code Digger
Yes, this is something similar to what I want. The .mht should auto-run the macro when the report opens in Excel so that it automatically gives the print out and doesnt even bring up the print dialogue window.
March 13, 2007, 03:09 PM
jgelona
Actually I am doing something like this right now. I saved a .mht in baseapp on the Reporting Server. I wrote a macro to do some formatting, turning filters on, freeze panes, etc. Just name the macro Auto_Open. Seems to work fine.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
March 14, 2007, 05:32 PM
ibidevelop
This may help.

http://www.informationbuilders.com/support/developers/macros.html

It worked for me.

Joe
March 14, 2007, 05:39 PM
FrankDutch
running a macro in excel just to get the report printed is a strange way to work.
I would give the report directly into PDF, no user can influence the layout anymore.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

June 08, 2010, 12:26 PM
Doug
Is there a setting within Excel which automatically sets the column width to a minimum based on the contents, similar to double-clicking the column dividers? Something other then an macro which is close to automatic but not directly automatic unless we do some work and implement that on the users machines. Having the users change a setting within Excel is acceptable. OK, maybe a macro which we can, through WebFOCUS PCHOLD, automatically execute.
June 08, 2010, 03:19 PM
njsden
This basic Excel VBA routine selects all cells in the worksheet and "commands" them to auto-fit their contents:

Sub ColumnWidth()
' Keyboard Shortcut: Ctrl+Shift+W
    Cells.Select
    Selection.Columns.AutoFit
End Sub


You could make it part of a file that can be later used as a template, or attempt to use the technique outlined in ibidevelop's reference above.

The routine can of course be improved to capture the current Worksheet and Cell/Range selected before any changes are made, and re-select them after the columns have been adjusted.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
June 08, 2010, 03:24 PM
njsden
The "manual" steps to make that happen in Excel are:

1. Select all cells (by clicking the empty area where row and column labels intersect)
2. Choose the following options from the menu: Format -> Column -> Autofit Selection

That's what I and some business users at my site do. As we are still using WebFOCUS 5.3.4 the use of Excel Templates is not a feasible option at the time.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.