Click here to Skip to main content
15,884,176 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionRuntime add com library reference Pin
BobbyStrain24-Jul-16 8:23
BobbyStrain24-Jul-16 8:23 
QuestionDisplay network signal strength (windows form app) Pin
dell-gl62m23-Jul-16 3:11
dell-gl62m23-Jul-16 3:11 
AnswerRe: Display network signal strength (windows form app) Pin
Richard MacCutchan23-Jul-16 4:09
mveRichard MacCutchan23-Jul-16 4:09 
GeneralRe: Display network signal strength (windows form app) Pin
dell-gl62m23-Jul-16 5:32
dell-gl62m23-Jul-16 5:32 
GeneralRe: Display network signal strength (windows form app) Pin
Richard MacCutchan23-Jul-16 5:44
mveRichard MacCutchan23-Jul-16 5:44 
GeneralRe: Display network signal strength (windows form app) Pin
dell-gl62m23-Jul-16 5:53
dell-gl62m23-Jul-16 5:53 
QuestionExtracting Outlook messages metadata to an Excel spreadsheet Pin
Alex911010-Jul-16 23:01
Alex911010-Jul-16 23:01 
AnswerRe: Extracting Outlook messages metadata to an Excel spreadsheet Pin
Alex911010-Jul-16 23:58
Alex911010-Jul-16 23:58 
I found this code:
VB.NET
Sub GetMailInfo()
' taken from http://www.mrexcel.com/forum/excel-questions/707690-extracting-outlook-messages-metadata-excel-spreadsheet.html
    
    
    Dim MyOutlook As Outlook.Application
    Dim msg As Outlook.MailItem
    Dim x As NameSpace
    Dim Path As String
    Dim i As Long

    Set MyOutlook = New Outlook.Application
    Set x = MyOutlook.GetNamespace("MAPI")
    
    Path = "C:\Users\Alexander.Scott-Zhuk\Desktop\Messages\"
    FileList = GetFileList(Path + "*.msg")

    Row = 1

    While Row <= UBound(FileList)

        Set msg = x.OpenSharedItem(Path + FileList(Row))

        Cells(Row + 1, 1) = msg.Subject
        Cells(Row + 1, 2) = msg.SenderName
        Cells(Row + 1, 3) = msg.SenderEmailAddress
        Cells(Row + 1, 4) = msg.CC
        Cells(Row + 1, 5) = msg.To
        Cells(Row + 1, 6) = msg.SentOn
        Cells(Row + 1, 7) = msg.Size
        If msg.Attachments.Count > 0 Then
            For i = 1 To msg.Attachments.Count
                Cells(Row + 1, 7 + i) = msg.Attachments.Item(i).FileName
            Next i
        End If
        
        Row = Row + 1
    Wend

End Sub
Function GetFileList(FileSpec As String) As Variant
'   Taken from http://spreadsheetpage.com/index.php/tip/getting_a_list_of_file_names_using_vba/
'   Returns an array of filenames that match FileSpec
'   If no matching files are found, it returns False


    Dim FileArray() As Variant
    Dim FileCount As Integer
    Dim FileName As String


    On Error GoTo NoFilesFound


    FileCount = 0
    FileName = Dir(FileSpec)
    If FileName = "" Then GoTo NoFilesFound


'   Loop until no more matching files are found
    Do While FileName <> ""
        FileCount = FileCount + 1
        ReDim Preserve FileArray(1 To FileCount)
        FileArray(FileCount) = FileName
        FileName = Dir()
    Loop
    GetFileList = FileArray
    Exit Function


'   Error handler
NoFilesFound:
        GetFileList = False
End Function

But it doesn't work for me. When I run the macro I receive a runtime error message:
"runtime error 1004 method 'cells' of object '_global' failed"
and when I click debug it highlights this line:
C#
Cells(Row + 1, 1) = msg.Subject

Do you have any clue, what am I doing wrong? Please help!
QuestionRe: Extracting Outlook messages metadata to an Excel spreadsheet Pin
Richard MacCutchan11-Jul-16 2:04
mveRichard MacCutchan11-Jul-16 2:04 
AnswerRe: Extracting Outlook messages metadata to an Excel spreadsheet Pin
Alex911011-Jul-16 2:20
Alex911011-Jul-16 2:20 
GeneralRe: Extracting Outlook messages metadata to an Excel spreadsheet Pin
Richard MacCutchan11-Jul-16 2:31
mveRichard MacCutchan11-Jul-16 2:31 
GeneralRe: Extracting Outlook messages metadata to an Excel spreadsheet Pin
Alex911011-Jul-16 3:05
Alex911011-Jul-16 3:05 
QuestionVb Image scaling Pin
Otekpo Emmanuel6-Jul-16 9:32
Otekpo Emmanuel6-Jul-16 9:32 
AnswerRe: Vb Image scaling Pin
Dave Kreskowiak6-Jul-16 10:12
mveDave Kreskowiak6-Jul-16 10:12 
QuestionUDP Protocol Pin
Member 125763031-Jul-16 2:06
Member 125763031-Jul-16 2:06 
QuestionRe: UDP Protocol Pin
Ralf Meier6-Jul-16 4:23
mveRalf Meier6-Jul-16 4:23 
AnswerRe: OT Pin
Richard MacCutchan16-Jul-16 1:33
mveRichard MacCutchan16-Jul-16 1:33 
GeneralRe: OT Pin
Ralf Meier16-Jul-16 10:12
mveRalf Meier16-Jul-16 10:12 
AnswerRe: UDP Protocol Pin
Simon_Whale6-Jul-16 5:08
Simon_Whale6-Jul-16 5:08 
QuestionBarcodes iTextSharp Pin
Petgil2527-Jun-16 9:24
Petgil2527-Jun-16 9:24 
QuestionVB Threading between classes update textbox Pin
saj65526-Jun-16 12:51
saj65526-Jun-16 12:51 
AnswerRe: VB Threading between classes update textbox Pin
Richard Deeming27-Jun-16 3:42
mveRichard Deeming27-Jun-16 3:42 
QuestionExample Lynx Grid Records Save to Database Pin
dongodu26-Jun-16 9:23
dongodu26-Jun-16 9:23 
QuestionLynx Grid Records Save to Database Pin
dongodu26-Jun-16 9:21
dongodu26-Jun-16 9:21 
QuestionWord For Mac 2016 - Set Margins Macro Pin
Member 1260347325-Jun-16 3:26
Member 1260347325-Jun-16 3:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.