Analyse de bilan comptable

RomainGe

XLDnaute Junior
Bonjour,

Je me suis amusé a créer un classeur excel pour me permettre d'analyser des bilans et calculer toute sorte de ratios.
Cependant je bloque pour :

1- Créer un bouton qui me permet de sauvegarder le fichier dans un dossier spécifique situé sur mon ordinateur et lors de la sauvegarde il faut que le nom du fichier soit égale au nom du client pour lequel le bilan a été saisie.

2- Envoyer une copie de ce fichier sur ma boite mail (lotus note)

Ensuite j'ai d'autres idées mais je préfère finir cette partie, si cela est réalisable bien sur.
 
Dernière édition:

JCGL

XLDnaute Barbatruc
Re : Analyse de bilan comptable

Bonjour à tous,

Pour archiver le fichier suivant le nom en B7 de Liasse CERFA :

VB:
Private Sub CommandButton1_Click()
    ActiveWorkbook.SaveAs Filename:="C:\Users\JCGL\Downloads\" & Feuil5.Cells(7, 2) & ".xls"
End Sub

Evidemment le chemin est à adapter ("C:\Users\JCGL\Downloads\")

A + à tous
 
Dernière édition:

RomainGe

XLDnaute Junior
Re : Analyse de bilan comptable

Bonjour à tous,

Pour archiver le fichier suivant le nom en B7 de Liasse CERFA :

VB:
Private Sub CommandButton1_Click()
    ActiveWorkbook.SaveAs Filename:="C:\Users\JCGL\Downloads\" & Feuil5.Cells(7, 2) & ".xls"
End Sub

Evidemment le chemin est à adapter ("C:\Users\JCGL\Downloads\")

A + à tous

Super !
Merci sa marche nikel.

Quelqu'un pour le mail ?!
 

JCGL

XLDnaute Barbatruc
Re : Analyse de bilan comptable

Bonjour à tous,

Ton code doit fonctionner.
Ou tu veux le "coupler" à l'archivage ?

VB:
Private Sub CommandButton1_Click()
    With ActiveWorkbook
        Application.DisplayAlerts = 0
        .SaveAs Filename:="C:\Users\JCGL\Downloads\" & Feuil5.Cells(7, 2) & ".xls" ' à modifier
        Application.DisplayAlerts = 1
        .SendMail Recipients:="romain.g@fai.fr" ' anonymisé
    End With
End Sub

Je t'ai envoyé un essai sur ta boite pro...
A + à tous
 
Dernière édition:

RomainGe

XLDnaute Junior
Re : Analyse de bilan comptable

Bonjour à tous,

Ton code doit fonctionner.
Ou tu veux le "coupler" à l'archivage ?

VB:
Private Sub CommandButton1_Click()
    With ActiveWorkbook
        Application.DisplayAlerts = 0
        .SaveAs Filename:="C:\Users\JCGL\Downloads\" & Feuil5.Cells(7, 2) & ".xls" ' à modifier
        Application.DisplayAlerts = 1
        .SendMail Recipients:="romain.g@fai.fr" ' anonymisé
    End With
End Sub

Je t'ai envoyé un essai sur ta boite pro...
A + à tous

marche pas chez moi, problème avec messagerie qui n'est pas paramétré par défaut....
 
C

Compte Supprimé 979

Guest
Re : Analyse de bilan comptable

Bonjour RomainGe
Salut mon ami JC ;)

Romain, tu comprendras que si tu n'est pas plus causant, on peut vite lâcher prise :rolleyes:

Sinon voici le code pour envoi via Lotus Note
VB:
Private Sub CommandButton1_Click()
    With ActiveWorkbook
        Application.DisplayAlerts = 0
        .SaveAs FileName:="C:\Users\JCGL\Downloads\" & Feuil5.Cells(7, 2) & ".xls" ' à modifier
       Application.DisplayAlerts = 1
       ' Envoyer le mail via la fonction
       SendNotesMail "LeSujet", "LeChemin+LeFichier", "romain.g@fai.fr", "Le texte", False
   End With
End Sub


Function SendNotesMail(Subject As String, attachment As String, _
      recipient As String, bodytext As String, SaveIt As Boolean) As Boolean
Dim Maildb        As Object
Dim UserName      As String
Dim MailDbName    As String
Dim MailDoc       As Object
Dim AttachME      As Object
Dim session       As Object
Dim EmbedObj      As Object


  On Error GoTo err_SendNotesMail


  'Start a session to notes
  Set session = CreateObject("Notes.NotesSession")


  'Get the sessions username and then calculate the mail file name
  'You may or may not need this as for MailDBname with some systems you
  'can pass an empty string
  UserName = session.UserName
  MailDbName = Mid$(UserName, 4, 1) & _
      Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"


  'Open the mail database in notes
  Set Maildb = session.GETDATABASE("", MailDbName)
  If Maildb.IsOpen = True Then
    'Already open for mail
  Else
    Maildb.OpenMail
  End If


  'Set up the new mail document
  Set MailDoc = Maildb.CreateDocument
  MailDoc.Form = "Memo"
  MailDoc.sendTo = recipient
  MailDoc.Subject = Subject
  MailDoc.Body = bodytext
  MailDoc.SaveMessageOnSend = SaveIt


  'Set up the embedded object and attachment and attach it
  If attachment <> "" And Dir(attachment) <> "" Then
    Set AttachME = MailDoc.CreateRichTextItem("Attachment")
    Set EmbedObj = AttachME.EmbedObject(1454, "", attachment, "Attachment")
    'MailDoc.CREATERICHTEXTITEM ("Attachment")
  End If


  'Send the document
  MailDoc.Send 0, recipient
  Maildb.Close
  'Clean Up
  Set Maildb = Nothing
  Set MailDoc = Nothing
  Set AttachME = Nothing
  Set session = Nothing
  Set EmbedObj = Nothing
  SendNotesMail = True


end_SendNotesMail:
  Exit Function


err_SendNotesMail:
  Select Case Err.Number
    Case 429:
      MsgBox "Error: " & vbCrLf & Err.Description & vbCrLf & _
            "Possible cause : " & vbCrLf & "Lotus Notes not installed", _
            vbCritical, "Error while initializing LotusNotes"
    Case Else:
      MsgBox Err.Description & Err.Number, vbCritical, "Error Lotus Notes Mail"
  End Select
  Resume end_SendNotesMail
End Function

A tester

A+
 

RomainGe

XLDnaute Junior
Re : Analyse de bilan comptable

Bonjour RomainGe
Salut mon ami JC ;)

Romain, tu comprendras que si tu n'est pas plus causant, on peut vite lâcher prise :rolleyes:

Sinon voici le code pour envoi via Lotus Note
VB:
Private Sub CommandButton1_Click()
    With ActiveWorkbook
        Application.DisplayAlerts = 0
        .SaveAs FileName:="C:\Users\JCGL\Downloads\" & Feuil5.Cells(7, 2) & ".xls" ' à modifier
       Application.DisplayAlerts = 1
       ' Envoyer le mail via la fonction
       SendNotesMail "LeSujet", "LeChemin+LeFichier", "romain.g@fai.fr", "Le texte", False
   End With
End Sub


Function SendNotesMail(Subject As String, attachment As String, _
      recipient As String, bodytext As String, SaveIt As Boolean) As Boolean
Dim Maildb        As Object
Dim UserName      As String
Dim MailDbName    As String
Dim MailDoc       As Object
Dim AttachME      As Object
Dim session       As Object
Dim EmbedObj      As Object


  On Error GoTo err_SendNotesMail


  'Start a session to notes
  Set session = CreateObject("Notes.NotesSession")


  'Get the sessions username and then calculate the mail file name
  'You may or may not need this as for MailDBname with some systems you
  'can pass an empty string
  UserName = session.UserName
  MailDbName = Mid$(UserName, 4, 1) & _
      Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"


  'Open the mail database in notes
  Set Maildb = session.GETDATABASE("", MailDbName)
  If Maildb.IsOpen = True Then
    'Already open for mail
  Else
    Maildb.OpenMail
  End If


  'Set up the new mail document
  Set MailDoc = Maildb.CreateDocument
  MailDoc.Form = "Memo"
  MailDoc.sendTo = recipient
  MailDoc.Subject = Subject
  MailDoc.Body = bodytext
  MailDoc.SaveMessageOnSend = SaveIt


  'Set up the embedded object and attachment and attach it
  If attachment <> "" And Dir(attachment) <> "" Then
    Set AttachME = MailDoc.CreateRichTextItem("Attachment")
    Set EmbedObj = AttachME.EmbedObject(1454, "", attachment, "Attachment")
    'MailDoc.CREATERICHTEXTITEM ("Attachment")
  End If


  'Send the document
  MailDoc.Send 0, recipient
  Maildb.Close
  'Clean Up
  Set Maildb = Nothing
  Set MailDoc = Nothing
  Set AttachME = Nothing
  Set session = Nothing
  Set EmbedObj = Nothing
  SendNotesMail = True


end_SendNotesMail:
  Exit Function


err_SendNotesMail:
  Select Case Err.Number
    Case 429:
      MsgBox "Error: " & vbCrLf & Err.Description & vbCrLf & _
            "Possible cause : " & vbCrLf & "Lotus Notes not installed", _
            vbCritical, "Error while initializing LotusNotes"
    Case Else:
      MsgBox Err.Description & Err.Number, vbCritical, "Error Lotus Notes Mail"
  End Select
  Resume end_SendNotesMail
End Function

A tester

A+

Oui j'ai compris c'est pas grave.

Merci pour ton code mais je n'arrive pas a le mettre en marche
J'ai tester le code donné par JC et voila l'erreur qui apparaît dans le fichier TEST V2 mais pas dans le fichier TEST V1

erreur.jpg
 

Pièces jointes

  • erreur.jpg
    erreur.jpg
    41.7 KB · Affichages: 165
  • erreur.jpg
    erreur.jpg
    41.7 KB · Affichages: 190
  • TEST V2.xlsm
    104 KB · Affichages: 140
  • TEST V1.xls
    213 KB · Affichages: 153
  • TEST V2.xlsm
    104 KB · Affichages: 134
  • TEST V1.xls
    213 KB · Affichages: 143
  • TEST V2.xlsm
    104 KB · Affichages: 126
  • TEST V1.xls
    213 KB · Affichages: 146
C

Compte Supprimé 979

Guest
Re : Analyse de bilan comptable

Re,

J'ai tester le code donné par JC et voila l'erreur qui apparaît dans le fichier TEST V2 mais pas dans le fichier TEST V1
Mais est-ce que le TextV1 fonctionne !?

Sinon dans les paramètres d'Internet Exploreur, il faut définir ton programme de messagerie par défaut
(voir copie d'écran)

A+
 

Pièces jointes

  • ScreenShot211.jpg
    ScreenShot211.jpg
    59.3 KB · Affichages: 244

RomainGe

XLDnaute Junior
Re : Analyse de bilan comptable

Re,


Mais est-ce que le TextV1 fonctionne !?

Sinon dans les paramètres d'Internet Exploreur, il faut définir ton programme de messagerie par défaut
(voir copie d'écran)

A+

Oui le test V1 fonctionne parfaitement si je clique sur le bouton "sauver modifs", ma boite lotus me prépare le mail que je peut envoyer.
J'utilise Google Chrome et je ne sais pas comment cela fonctionne, mais si dans un cas cela marche pourquoi pas dans l'autre ?

Cordialement,
 

JCGL

XLDnaute Barbatruc
Re : Analyse de bilan comptable

Bonjour à tous,
Salut mon Nono,

A ceci, notre ami a répondu en courriel privé :

Bonjour à tous,

Ton code doit fonctionner.
Ou tu veux le "coupler" à l'archivage ?

VB:
Private Sub CommandButton1_Click()
    With ActiveWorkbook
        Application.DisplayAlerts = 0
        .SaveAs Filename:="C:\Users\JCGL\Downloads\" & Feuil5.Cells(7, 2) & ".xls" ' à modifier
        Application.DisplayAlerts = 1
        .SendMail Recipients:="romain.g@fai.fr" ' anonymisé
    End With
End Sub

Je t'ai envoyé un essai sur ta boite pro...
A + à tous

Bonjour,

Effectivement j'ai bien reçu votre fichieret cela fonctionne !
Merci beaucoup pour votre aide.

Cordialement,

Romain

A + à tous
 

Discussions similaires

Réponses
2
Affichages
620
Membre supprimé 341069
M

Statistiques des forums

Discussions
312 410
Messages
2 088 157
Membres
103 747
dernier inscrit
Famille36