Adjust an analysis for publication on InSite (local installation)
You include the 'PublishAnalysis' macro in the analysis. When you publish the analysis, the macro is called to generate the web files. If you use the Command Line Utility to publish the analysis, the 'PublishAnalysis' macro is called and the macro is published as a web page.
One of the functions (GenerateXMLforInSite) generates an XML file. The XML file is used for calling the analysis. Depending on the type of site, the XML file has one of following regular names:
- insite.xml
- outsite.xml
You also have to add this folder on your system.
Add a macro and a function to the analysis
Note:
For the Social analysis (Profit), you do not perform this step. To record settings, you follow a separate procedure. You therefore do not adjust the 'PublishAnalysis' macro.
If you want to publish an analysis automatically, it should contain both the 'PublishAnalysis' macro and the 'GenerateXMLForInsite' function.
If you were already publishing analyses in previous Builds of Profit, these analyses already contain the 'PublishAnalysis' macro. Amongst other things, this macro determines which Excel worksheet is published. You adjust this macro and add the 'GenerateXMLForInsite' function.Every analysis is published in a separate folder. You record this folder in the 'PublishAnalysis' macro. The name of the folder must be the same as the name of the analysis in Profit.
In the procedure below, it is assumed that you adjust an existing macro. However, you can also download sample code.
To change the 'PublishAnalysis' macro and add the 'GenerateXMLForInsite' function:
- Go to: Profit Windows.
- Go to:
- General / Output / Management / Analysis (all analyses)
- CRM / Output / Management / Analysis
- Financial / Output / Management / Analysis
- Fiscal / Output / Management / Analysis
- HR / Output / Management / HRM analysis
- HR / Output / Management / Payroll analysis
- Order Management / Output / Management / Analysis
- Double-click on the analysis.
- Click on: Design.
The analysis is opened in Microsoft Excel.
- Go to the tab: ‘Image.
- Go to: 'Macros / ‘Display macros'.
- Select the 'PublishAnalysis' macro.
- Click on 'Edit'.
The macro editor is started and the old macro is shown.
You are now going to change the macro.
- Copy the following code to the Clipboard:
Dim strFilePath As String
Dim strFileName As String
Dim strFileLocation As String
Dim strNameWorkbook As String
Dim strHeightInPixels As String
Dim strWidthInPixels As String
'Main folder and HTM name
strFileLocation = "C:\Localfolder\Environment\"
strFileName = "Cockpit.htm"
'Determine the analysis name
If Right(Application.ActiveWorkbook.Name, 4) = ".xls" Then
strNameWorkbook = Left(Application.ActiveWorkbook.Name, Len(Application.ActiveWorkbook.Name) - 4)
Else
strNameWorkbook = Left(Application.ActiveWorkbook.Name, Len(Application.ActiveWorkbook.Name) - 5)
End If
strHeightInPixels = "1500px"
strWidthInPixels = "990px"
If Right(strFileLocation, 1) = "\" Then
strFilePath = strFileLocation & strNameWorkbook & "\"
Else
strFilePath = strFileLocation & "\" & strNameWorkbook & "\"
End If
'Add publication folder if it does not exist.
If Dir(strFilePath, vbDirectory) = "" Then
MkDir strFilePath
End If
- Paste the code in the macro, under 'Sub PublishAnalysis'.
- You change the main folder for the analysis.
The sample code includes the line:
strFileLocation = "C:\Localfolder\Environment"
Suppose you want to publish to 'C:\Cockpits' and the environment is 'EnYoi'. In that case the folder is:
strFileLocation = "C:\Cockpits\EnYoi"
- The code from the old macro also contains a file location (the publication folder and the HTM name of the cockpit page).
New path: 'LocalServer\cockpits\ + environment name + analysis name + pagename.htm
Example:
Environment name: ENYOI
Main folder for this environment:C:\Cockpits\EnYoi\
Name of an analysis to be published: Managementinfo
Publication folder of the cockpit: C:\Cockpits\EnYoi\Managementinfo
Complete file path:
C:\Cockpits\EnYoi\ + managementinfo (=analysis name) + cockpit.htm (=page name)
Result:
C:\Cockpits\EnYoi\managementinfo\cockpit.htm
- Copy the following code to the Clipboard:
GenerateXMLForInsite strHeightInPixels, strWidthInPixels, strFilePath, strFileName
- Paste the code in the macro , above 'End Sub'.
- Open the file with the sample code of the functions.
- Copy the complete sample code of the function.
- Paste the sample code in the window, under the macro.
Activate Microsoft XML
This Microsoft XML version is present if you have installed Profit. If not, use the 'Aanvullende bestanden' option to download 'MSXML (Microsoft XML Core Services)' from the AFAS Customer portal.
To activate Microsoft XML:
- In the Excel macro editor, go to 'Tools / References'.
- Select the 'Microsoft XML v4.0' check box.
- Click on: OK.
See also: