28 October 2021

VBA: Save text file UTF-8 encoded

Dim fsT As Object
Set fsT = CreateObject("ADODB.Stream")

fsT.Type = 2 'Specify stream type - we want To save text/string data.
fsT.Charset = "utf-8" 'Specify charset For the source text data.
fsT.Open 'Open the stream And write binary data To the object

fsT.WriteText "special characters: äöüß"
fsT.SaveToFile sFileName, 2 'Save binary data To disk

Found here.

02 September 2021

VBA - Outlook_Export_Tasks.bas

'--##2021-10-28 - Boso -                    FullFilePath  //  utf-8
Option Explicit

Dim fs As Scripting.FileSystemObject
Dim txt

Private Sub ACapo()

    txt.WriteText vbCrLf
    
End Sub

Public Function parseString(s) As String

    Dim res As String

    If IsNull(s) Then
        res = ""
    Else
        res = ""
        res = res & Chr(34)
        res = res & Replace(s, Chr(34), Chr(34) & Chr(34))
        res = res & Chr(34)
    End If
    
    parseString = res

End Function

Private Sub ScriviRiga(taskFolder As Outlook.Folder)

    Dim olnameSpace As Outlook.NameSpace
    Dim tasks As Outlook.Items
    Dim x As Long
    Dim tsk As Outlook.TaskItem
    Dim s As String
    Dim wDataCrea As String
    Dim wDataScad As String

    Set tasks = taskFolder.Items

    Set tasks = taskFolder.Items

    For x = 1 To tasks.Count
        Set tsk = tasks.Item(x)

        If Not tsk.Complete Then
            Debug.Print Space(4) & Left(tsk.Subject, 50)
            
            With tsk
                wDataScad = ""
                If .DueDate <> DateSerial(4501, 1, 1) Then
                    wDataScad = .DueDate
                End If
                
                wDataCrea = ""
                If .CreationTime <> DateSerial(4501, 1, 1) Then
                    wDataCrea = .CreationTime
                End If
                
                s = taskFolder.Name & "|" & wDataCrea & "|" & wDataScad & "|" & parseString(.Subject) & "|" & parseString(.Body)
                txt.WriteText s
                ACapo
                
'                If LCase(.Subject) Like LCase("*Port of Earth*") Then Stop
            End With
            
        End If
    Next x

    Set olnameSpace = Nothing
    Set tasks = Nothing
    Set tsk = Nothing
    
End Sub

Private Sub EnumerateFolders(ByVal oFolder As Outlook.Folder)
    
    Dim folders As Outlook.folders
    Dim Folder As Outlook.Folder
    Dim foldercount As Integer
    
    On Error Resume Next
    Set folders = oFolder.folders
    foldercount = folders.Count
    
    'Check if there are any folders below oFolder
    If foldercount Then
        For Each Folder In folders
            
            If LCase(Folder.FolderPath) Like "*task*" Then
                Debug.Print Folder.Name
                ScriviRiga Folder
                EnumerateFolders Folder
            End If
            
        Next
    End If


    Set folders = Nothing
    Set Folder = Nothing

End Sub

Private Sub InitTXT(FullFilePath As String)
    
    Dim s As String
    
    Set txt = CreateObject("ADODB.Stream")

    With txt
        .Type = 2               ' Specify stream type - we want To save text/string data.
        .Charset = "utf-8"      ' Specify charset For the source text data.
        .Open                   ' Open the stream And write binary data To the object
    End With
    
    s = "FolderName|CreationTime|DueDate|Subject|Body"
    txt.WriteText s
    ACapo

End Sub


Sub Main()
    
    Dim colStores As Outlook.Stores
    Dim oStore As Outlook.Store
    Dim oRoot As Outlook.Folder
    Dim FullFilePath As String

    
    Set fs = New Scripting.FileSystemObject
    
    FullFilePath = "C:\Users\Boso\Downloads\BakToDo\Tasks.csv"
    
    InitTXT FullFilePath
    
    
    On Error Resume Next
    Set colStores = Application.Session.Stores
    
    For Each oStore In colStores
        Set oRoot = oStore.GetRootFolder
        Debug.Print (oRoot.FolderPath)
        EnumerateFolders oRoot
    Next
    
    txt.SaveToFile FullFilePath, 2  'Save binary data To disk
    txt.Close
    
    Set txt = Nothing
    Set fs = Nothing
    
    Set colStores = Nothing
    Set oStore = Nothing
    Set oRoot = Nothing
    
    
    Debug.Print
    Debug.Print "** FINE"
    Debug.Print
    Debug.Print "File creato: " & FullFilePath
    
End Sub

27 May 2021

Visual Studio: how to temporarily deactivate all try / catch blocks

To catch exceptions the moment they're thrown ("first-chance exceptions" in Win32 parlance):
  • in VS2008: go to Debug, Exceptions...
  • in VS2015 (and later): this has been moved to Debug > Windows > Exception Settings
Then check the box Thrown for Common Language Runtime Exceptions:


Found here.

16 April 2021

Adobe Acrobat - Disable right-click context menu

Run the Command Promt (or PowerShell) as Administrator and enter these commands:
cd /d C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat Elements
regsvr32.exe /u ContextMenuShim64.dll
regsvr32.exe /u ContextMenu64.dll
regsvr32.exe /u ContextMenu.dll
that will remove Adobe Acrobat DC context menu without deleting the files.

Via.

01 March 2021

Sql Server Management Studio - SSMS 18.8 crashes when re-docking tabs

How to fix: Close all SSMS windows, and find your SQL Mgt Studio EXE file, mine was in:

C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE

If you cant find it, right click your shortcut you use to open SSMS and go Properties > Open File Location

Once you have found this, you will also find a file called Ssms.exe.config, open up a Notepad in Administrator Mode, and edit this file

You will then need to find an xml tag called <AppContextSwitchOverrides>, and APPEND (not replace) the following exactly:
;Switch.System.Windows.Interop.MouseInput.OptOutOfMoveToChromedWindowFix=true; Switch.System.Windows.Interop.MouseInput.DoNotOptOutOfMoveToChromedWindowFix=true

Via: https://docs.microsoft.com/answers/answers/274201/view.html