blog.devbroker.org author="Patrick Rabian" about="c#, sharepoint, biztalk, team system resources" more="news, samples, tips for .NET world's developers !"

Internet Explorer : ouvrir un document Excel depuis un lien hypertext.

Thursday, 26 June 2008 19:51 by prabian

Voici comment ouvrir un document Excel sous forme de lien hypertexte à partir d'un script javascript puis vbscript.
Il est important que le niveau de sécurité du navigateur autorise l'execution de composants ActiveX.
Ces scripts peuvent être utiles dans un contexte ou seul Internet Explorer est utilisé. (contrainte d'execution ActiveX).

JAVASCRIPT

<script language="javascript" type="text/javascript">
<!--

function OpenExcelDocument(documentUrl)
{    
    if (!window.ActiveXObject)
    {
        alert('Attention ! Les paramètres de sécurité de votre poste n\'autorisent pas le lancement de composants ActiveX.');
        return;
    }

    excelApp = new ActiveXObject("Excel.Application");  

    if(excelApp==null)
    {
        alert('Attention ! La version d\'Excel requise ne semble pas être installée.');
        return;
    }

    excelApp.WorkBooks.Open(documentUrl);
    excelApp.Application.Visible = true;    
    excelApp.UserControl = true;    
}

//-->
</script>

[...] 

<a href="javascript:OpenExcelDocument('Fichier.xls');">LIEN</a> 

 

VBSCRIPT

<script language="vbscript" type="text/vbscript">
     
   Sub OpenExcelDoc(strLocation)
    On Error Resume Next
    Dim objExcel
    Set objExcel = CreateObject("Excel.Application")
    If Err.number <> 0 Then
        MsgBox "Attention ! Les paramètres de sécurité de votre poste n'autorisent pas le lancement de composants ActiveX ou la version d'Excel requise ne semble pas être installée."
        Exit Sub
    End If
    objExcel.WorkBooks.Open strLocation
    objExcel.Visible = true    
    objExcel.UserControl = true
   End Sub
   
</script>

[...]

<a href="#" language="vbscript" onClick="OpenExcelDoc('Fichier.xls')">LIEN</a>
 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   COM | Javascript | Office | Win32
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

.NET assembly called from unmanaged application without COM registration

Saturday, 26 January 2008 10:43 by prabian

.NET Assembly are easy to deploy even with different versions on the same server.
Since Windows XP SP2 or Windows Server 2003, COM components could be used without registration (called Registration-Free COM)
If you are using a "COM visible" .NET assembly, it should be registered on the system through registry and only one version could be available for the same COM component…the solution is to use a manifest to create a dependency between the calling application and the assembly.

Read first this article : http://www.devx.com/vb/Article/32888/1954
and see this interesting article with a sample : Registration-Free Activation of .NET-Based Components: A Walkthrough
In this sample, "client.exe" is an unmanaged application (compiled with VB6 or VC++) that calls a .NET assembly "SideBySide.dll" (compiled with C# or VB.NET).

The dependency manifest file looks like :

<?xml version="1.0" encoding="UTF-8" standalone="yes"

?>
          <
assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
          <
assemblyIdentity type = "win32" name = "client" version = "1.0.0.0" />
          <
dependency>
                    <
dependentAssembly>
                              <
assemblyIdentity type="win32" name="SideBySide" version="1.0.0.0" />
                    </
dependentAssembly>
          </
dependency>
</
assembly>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   , ,
Categories:   COM | Win32 | Windows
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed