davman2002
Programmer
I have a program that creates a text file. I would like to know if anyone can help me with converting the contents of that file to excel. Or is there a way to automactically convert it to excel instead of a text file.
Here is my code
Private Sub mnuConvert_Click()
dlgMain.Filter = "Text Files|*.txt|All Files|*.*"
dlgMain.ShowSave
'Get reference to Outlook
Set objOutlook = New Outlook.Application
Set ns = objOutlook.GetNamespace("MAPI"
Set fldrRoot = ns.Folders.GetFirst
Me.MousePointer = vbArrowHourglass
Open dlgMain.FileName For Output As #1
For Each fldr In fldrRoot.Folders
On Error Resume Next
For Each mi In fldr.Items
Time = mi.ReceivedTime
strName = mi.SenderName
Subject = mi.Subject
' Print Output to file
Write #1, fldr.Name, Time, strName, Subject
Next
Next
Close #1
'Clear Memory
Set mi = Nothing
Set fldr = Nothing
Set fldrRoot = Nothing
Set ns = Nothing
Set objOutlook = Nothing
Me.MousePointer = vbArrow
Call gen_preview_Click
End Sub
Here is my code
Private Sub mnuConvert_Click()
dlgMain.Filter = "Text Files|*.txt|All Files|*.*"
dlgMain.ShowSave
'Get reference to Outlook
Set objOutlook = New Outlook.Application
Set ns = objOutlook.GetNamespace("MAPI"
Set fldrRoot = ns.Folders.GetFirst
Me.MousePointer = vbArrowHourglass
Open dlgMain.FileName For Output As #1
For Each fldr In fldrRoot.Folders
On Error Resume Next
For Each mi In fldr.Items
Time = mi.ReceivedTime
strName = mi.SenderName
Subject = mi.Subject
' Print Output to file
Write #1, fldr.Name, Time, strName, Subject
Next
Next
Close #1
'Clear Memory
Set mi = Nothing
Set fldr = Nothing
Set fldrRoot = Nothing
Set ns = Nothing
Set objOutlook = Nothing
Me.MousePointer = vbArrow
Call gen_preview_Click
End Sub