Tagged: VBA Toggle Comment Threads | Keyboard Shortcuts

  • Mukesh Dak 15:05 on December 31, 2022 Permalink |
    Tags: VBA   

    sum of digits of a number in vba 

    REM This function
    Public Function digitSum(x As Integer)
    Dim I As Integer
    Dim SumDigit As Integer
    SumDigit = 0
    For I = 1 To 10
    SumDigit = SumDigit + (x Mod 10)
    x = Int(x / 10)
    MsgBox "Value of " + I + " value of " + SumDigit
    If (x < 1) Then Exit Function
    Next I
    digitSum = SumDigit
    End Function

    Advertisement
     
  • Mukesh Dak 00:19 on November 7, 2022 Permalink |
    Tags: VBA   

    Save Outlook attachments 

    Public Sub SaveOutlookAttachmentsToDisk(MItem As Outlook.MailItem)
    Dim oOutlookAttachment As Outlook.Attachment
    Dim sSaveAttachmentsFolder As String
    sSaveAttachmentsFolder = “C:\Users\dakm\Desktop\attachments\”

    ‘ Not to save following files.
    arrIgnoreFiles = Array(“graycol.gif”, “image001.gif”)

    For Each oOutlookAttachment In MItem.Attachments
    If IsInArray(oOutlookAttachment.DisplayName, arrIgnoreFiles) = False Then
    oOutlookAttachment.SaveAsFile sSaveAttachmentsFolder & oOutlookAttachment.DisplayName
    End If
    Next
    End Sub

    Function IsInArray(stringToBeFound As String, arr As Variant) As Boolean
    IsInArray = UBound(Filter(arr, stringToBeFound)) > -1
    End Function

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel