
Range(“B” & lRow).Value = olMail.With the vast growth of organization it’s quiet common for the organizations to starts maintaining it’s database in Excel spreadsheet. LRow = oXLws.Range(“A” & ).End(xlUp).Row + 1 Set oXLws = oXLwb.Sheets(“Spectrum emails”)

Set oXLwb = (“S:\Personal Folders\Templates\Buyflow import template.xlsm”) Set oXLApp = CreateObject(“Excel.Application”) Set oXLApp = GetObject(, “Excel.Application”) Set olNS = Application.GetNamespace(“MAPI”) How can I get the macro to turn off wrap text for either column A or the cell it just wrote to?ĭim strID As String, olNS As Outlook.NameSpaceĭim oXLApp As Object, oXLwb As Object, oXLws As Object A2:A50, etc., but the same thing happens. I’ve tried different iterations of the range, i.e. I tried to set the range to column A and turn of the wrap text, but it fails every time. The issue is, the email body has a lot of line breaks and when it writes to the sheet, Excel automatically wraps the text.

#Macro to import data from excel to excel code#
I found some code to export an email body to an excel sheet below (modified for my purposes, of course). Range(“eMail_text”).Offset(i, 0).Value = OutlookMail.Body Range(“eMail_sender”).Offset(i, 0).Value = OutlookMail.SenderName Range(“eMail_date”).Offset(i, 0).Value = OutlookMail.ReceivedTime Range(“eMail_subject”).Offset(i, 0).Value = OutlookMail.Subject If OutlookMail.ReceivedTime >= Range(“From_date”).Value Then Set OutlookNamespace = OutlookApp.GetNamespace(“MAPI”) Set Folder = Session.Folders(strMailboxName) StrMailboxName = “Internal Team 1” ‘name of shared inbox Hi There, I know im kinda late on this thread, but i stumbled across your macro, and i found a way to use this with a shared inbox/folder. It’s a pretty simple VBA procedure, but it can be very useful if you have to deal with a lot of similar emails. Range("eMail_text").Offset(i, 0).Value = OutlookMail.Body Range("eMail_sender").Offset(i, 0).Value = OutlookMail.SenderName Range("eMail_date").Offset(i, 0).Value = OutlookMail.ReceivedTime Range("eMail_subject").Offset(i, 0).Value = OutlookMail.Subject If OutlookMail.ReceivedTime >= Range("From_date").Value Then Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox).Folders("Net Sales Report").Folders("Sales") Set OutlookNamespace = OutlookApp.GetNamespace("MAPI") The main text body from emails will be imported just below this cell. eMail_text – This cell contains the Email Text column heading.Sender information from emails will be imported just below this cell. eMail_sender – This cell contains the Sender column heading.Date received from emails will be imported just below this cell. eMail_date – This cell contains the Date column heading.

Subjects from emails will be imported just below this cell.

In this example I’m going to be importing from an Outlook folder called Inbox/Net Sales Report/Sales. In the visual basic editor, go to Tools then References and check the box next to it and press OK button to enable it.
#Macro to import data from excel to excel how to#
If you’re unfamiliar with VBA, then it’s probably a good idea to read this post about How To Use The VBA Code You Find Online before continuing reading and working with the completed workbook.įor this code you will need the Microsoft Outlook 16.0 Object Library enabled.
