Skip to content

Instantly share code, notes, and snippets.

@Mandorlo
Mandorlo / AD_LIB.vbs
Created October 5, 2018 22:14
ActiveDirectory AD library
' reference : Microsoft ActiveX Data Objects 2.8 library
' trouve la date d'expiration du compte AD du user username
Function AD_AccountExpirationDate(ByVal username As String) As Date
distinguishedName = AD_UserAccDistinguishedName(username)
On Error GoTo myerr
Set objUser = GetObject _
("LDAP://" & distinguishedName)
On Error GoTo 0
' auto-porteur :)
Function fileExists(ByVal fichier As String) As Boolean
fileExists = (Dir$(fichier, vbNormal) <> "") And (fichier <> "")
End Function
' affiche la boîte de dialogue pour choisir un dossier
Function GetFolder(Optional strpath As String = "") As String
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
@Mandorlo
Mandorlo / OUTLOOK_MACROS.vbs
Created October 5, 2018 22:16
- sauvegarde du mail sélectionné dans un répertoire spécifique et copie du lien dans le presse papier - insertion d'un fichier HTML dans le corps du mail - création d'un groupe de contacts à partir des destinataires
Public Const save_mail_path = "D:\Utilisateurs\carlo.bauge\Documents\LOREAL\mails\" ' ne pas oublier le "\" final
' sauvegarde les mails sélectionnés et copie les liens vers ces mails
Sub savemail_copypath()
Dim objItem As MailItem
Set objItem = ActiveExplorer.Selection.Item(1)
myGUID = getGUID(objItem.SenderEmailAddress & objItem.To & objItem.Body & objItem.Subject)
If myGUID <> "" And Not fileExists(save_mail_path & myGUID & ".msg") Then
objItem.SaveAs save_mail_path & myGUID & ".msg", olMSG
setClipboard save_mail_path & myGUID & ".msg"
@Mandorlo
Mandorlo / LIB_OFFICE_EXTRACTOR.vbs
Created October 5, 2018 22:18
Librairie pour extraire des informations depuis des documents Office TODO nettoyer car il y a des fonctions qui ne servent à rien
Const sep_postproc = ";"
' récupère une information d'un doc Word
Function getObjectListDOC(ByVal fichier As String, ByVal myrules)
' on ouvre Word et le fichier
Dim oWord As Word.Application
Dim oDoc As Document
Set oWord = New Word.Application
If Mid(fichier, 2, 1) <> ":" Then
fichier = ActiveWorkbook.path & "\" & fichier
@Mandorlo
Mandorlo / LIB_SQLITE_API.vbs
Created October 5, 2018 22:18
Librairie pour SQLITE nécessite d'avoir quelque part les fichiers sqlite3.dll, SQLite3_StdCall.dll, sqlite3.exe (option)
Option Explicit
' Notes:
' Microsoft uses UTF-16, little endian byte order.
Private Const JULIANDAY_OFFSET As Double = 2415018.5
' Returned from SQLite3Initialize
Public Const SQLITE_INIT_OK As Long = 0
Public Const SQLITE_INIT_ERROR As Long = 1
@Mandorlo
Mandorlo / LIB_IE.vbs
Created October 5, 2018 22:19
Librairie pour Internet Explorer - navigator @dependsOn multiSplit (LIB_STRING) and trier (LIB_LIST)
Public Declare Sub Sleep Lib "kernel32" (ByVal lngMilliSeconds As Long)
Public Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Sub navigator(ByVal myNav As Collection)
Dim s As String
' on navigue
Dim ie As SHDocVw.InternetExplorer
Set ie = Nothing
@Mandorlo
Mandorlo / SaveClipBoardImage.vbs
Created October 5, 2018 22:21
Sauve l'image qui se trouve dans le presse-papier (utilise PowerPoint)
Sub SaveClipBoardImage(ByVal path As String)
Dim oPPT As PowerPoint.Application
Set oPPT = New PowerPoint.Application
Dim pptLayout As CustomLayout
Dim myslide As Slide
Set newppt = oPPT.Presentations.Add(msoTrue)
Set pptLayout = newppt.Designs(1).SlideMaster.CustomLayouts(1)
With newppt.Slides.AddSlide(1, pptLayout)
.Shapes.PasteSpecial DataType:=ppPastePNG

##lister_rdv## liste les RDV dans les nb_jours prochains jours filtre = par ex "Subject,Start"

Function lister_rdv(Optional ByVal filtre As String = "", Optional ByVal nb_jours As Integer = -1)

##proposeMeeting## même arguments que pour getFreeBusy mais dans time_params il faut ajouter au début "trouve-moi un créneau de 1h du 07/12/2015 au 11/12/2015 de 14h à 18h par pas de 30min"

Documentation LIB_SQLITE_EXCEL

Cette librairie est à utiliser avec LIB_SQLITE_API et offre des fonctions plus haut niveau pour utiliser Excel avec SQLite.

SQLite_LinkTableDB

Lance une requete sur la base et affiche les résultats dans le tableau.

Public Sub SQLite_LinkTableDB( _

DOCUMENTATION LIB_PASSBOX

Tout ce code ne sert à exposer qu'une seule fonction :

Function InputBoxDK(Prompt As String, Optional Title As String, _
            Optional Default As String, _
            Optional Xpos As Long, _
            Optional Ypos As Long, _
            Optional Helpfile As String, _
 Optional Context As Long) As String