IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Visual Studio Discussion :

Appel excel par vb net


Sujet :

Visual Studio

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Décembre 2010
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2010
    Messages : 13
    Points : 5
    Points
    5
    Par défaut Appel excel par vb net
    Bonjour,

    J'aimerais savoir pourquoi l'ouverture du fichier excel pose probleme avec ce code fait sur Vb net.
    J'ai besoin de votre aide SVP.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    Option Strict Off
    Imports System.IO
    Imports System.Reflection ' For Missing.Value and BindingFlags
    Imports Excel = Microsoft.Office.Interop.Excel
    Module Resultat_Excel
        'Friend WithEvents Ex As Excel.Application
        'Friend WithEvents ThisDocument As Excel.Worksheets
    
        Public Sub Affichage_Resultats_Excel()
            Dim xl As New Excel.Application
            xl = New Excel.Application
            Dim msg1, msg2, msg3 As String
            If xl Is Nothing Then
                MsgBox("ERROR: EXCEL couldn't be started!")
                'Environment.ExitCode = 0
                Exit Sub
            End If
            xl.Visible = False 'affiche le document
            xl.Workbooks.Add() 'ajouter un nouveau classeur ==> Ligne de blocage du code
            If l_strFileName = "" Then
                xl.ActiveWorkbook.SaveAs("C:\NouveauClasseur") 'Enregistrer sous le classeur 
            Else
                Dim toto As String = l_strFileName
                Call Lecture_chaine(toto)
                msg1 = "C:\" & toto
                xl.ActiveWorkbook.SaveAs(msg1) 'Enregistrer sous le classeur 
            End If
    
    
            xl.ActiveWorkbook.Worksheets("Feuil1").Select() 'Selectionner une feuille 
    
            xl.ActiveWorkbook.Worksheets("Feuil1").Name = "1" 'Renommer une feuille 
            xl.ActiveWorkbook.Worksheets("1").Range("A1").Value = "Noeuds / Cas"
            xl.ActiveWorkbook.Worksheets("1").cells(1, 2).Value = "Fx"
            xl.ActiveWorkbook.Worksheets("1").Range("C1").Value = "Fy"
    Cdlt

  2. #2
    Futur Membre du Club
    Profil pro
    Inscrit en
    Décembre 2010
    Messages
    13
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2010
    Messages : 13
    Points : 5
    Points
    5
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    Option Strict Off
    Imports System.IO
    Imports System.Reflection ' For Missing.Value and BindingFlags
    Imports Excel = Microsoft.Office.Interop.Excel
    Module Resultat_Excel
        'Friend WithEvents Ex As Excel.Application
        'Friend WithEvents ThisDocument As Excel.Worksheets
    
        Public Sub Affichage_Resultats_Excel()
            Dim xl As New Excel.Application
            xl = New Excel.Application
            Dim msg1, msg2, msg3 As String
            If xl Is Nothing Then
                MsgBox("ERROR: EXCEL couldn't be started!")
                'Environment.ExitCode = 0
                Exit Sub
            End If
            xl.Visible = False 'affiche le document
            xl.Workbooks.Add() 'ajouter un nouveau classeur
            If l_strFileName = "" Then
                xl.ActiveWorkbook.SaveAs("C:\NouveauClasseur") 'Enregistrer sous le classeur  ==> C'est là ou il y a blocage; j'ai fait une erreur sur le précédent poste
            Else
                Dim toto As String = l_strFileName
                Call Lecture_chaine(toto)
                msg1 = "C:\" & toto
                xl.ActiveWorkbook.SaveAs(msg1) 'Enregistrer sous le classeur 
            End If
    
    
            xl.ActiveWorkbook.Worksheets("Feuil1").Select() 'Selectionner une feuille 
    
            xl.ActiveWorkbook.Worksheets("Feuil1").Name = "1" 'Renommer une feuille 
            xl.ActiveWorkbook.Worksheets("1").Range("A1").Value = "Noeuds / Cas"
            xl.ActiveWorkbook.Worksheets("1").cells(1, 2).Value = "Fx"
            xl.ActiveWorkbook.Worksheets("1").Range("C1").Value = "Fy"

Discussions similaires

  1. [Débutant] possibilité execution macro excel par vb.net a partir de VB.net
    Par Pexou dans le forum VB.NET
    Réponses: 0
    Dernier message: 17/11/2013, 19h05
  2. Appel fichier excel par vba
    Par wachoo31 dans le forum VBA Access
    Réponses: 2
    Dernier message: 05/04/2009, 12h13
  3. pilotage d'excel par vb net
    Par ruliane dans le forum VB.NET
    Réponses: 4
    Dernier message: 03/07/2008, 09h44
  4. Format nombres Excel importés par VB.net
    Par vérokit dans le forum VB.NET
    Réponses: 4
    Dernier message: 22/02/2008, 08h55
  5. [VB.Net] Problème appel fonction par un bouton
    Par balibo dans le forum ASP.NET
    Réponses: 4
    Dernier message: 25/11/2005, 11h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo