outlook-vba

Outlook 2013 VBA display Shared Calendar

只愿长相守 提交于 2019-12-11 09:25:52
问题 I've got some VBa code that opens the Calendar in a new window, but I now need it to display the shared calendars that I've already got setup, but the only code I can find Creates a new shared calendar in the new window i've just created; Sub DispCalendars() Dim myOlApp As Outlook.Application Dim myNms As Outlook.NameSpace Dim myFolder As Outlook.MAPIFolder Dim myRecipient As Outlook.Recipient Dim myExplorer As Outlook.Explorer Dim SharedFolder As Outlook.MAPIFolder Set myOlApp = CreateObject

Move outlook mail from one mailbox inbox to different folder in same mailbox

人盡茶涼 提交于 2019-12-11 09:19:46
问题 I have several mailboxes which I can see in my Outlook profile. One of the mailboxes, let's call it "Mailbox - HUR" receives messages constantly. presently one of my team goes into the inbox of this mailbox every day and moves (drag and drop) the messages into a subfolder of the inbox called Archive (we're an imaginative lot!) if the messages are greater than 24 hours old. Is there any way that a macro can be set up to do this task? I know my simple way around VBA but have never used it with

Loop though body only of an email

不问归期 提交于 2019-12-11 08:55:37
问题 I want to run a macro only affecting the body of the email currently open (e.g., not the signature). The code below works if the body is selected. How can we do it without need for selecting? Sub FixParagraphSpacing() Dim objOL As Application Dim sel As Object Set objOL = Application Set sel = objOL.ActiveInspector().WordEditor.Application.Selection For Each para In sel.Paragraphs para.SpaceBefore = 0.3 * 11 para.SpaceAfter = 0 Next para End Sub 回答1: Here is the solution Sub

VBA Excel to Outlook font formatting

孤街醉人 提交于 2019-12-11 08:38:16
问题 I am currently working on a process automation for my work. Basically, the macro analyses the data and creates an email with results. Everything works perfectly fine, besides the fact I have absolutely no clue how to implement my font formatting into Outlook's email body. I cannot set font formatting to constant value as each row's formatting varies and is depended on excel formulas and conditional formattings in my worksheet. The function which creates the HTML body looks as below: Private

XmlDocument in Outlook VBA

倖福魔咒の 提交于 2019-12-11 08:37:10
问题 I am trying to adapt this answer, which I believe is in VB.NET , for use with Outlook VBA . I made some progress by getting the syntax corrected for VBA, but I do not know how to resolve "Compile error: User-defined type not defined" on the line Dim CurrentXML As XmlDocument Tool > References includes Microsoft XML, v6.0 but searching for XmlDocument in Object Browser returns no results. The complete code is as follows: Sub Search2() ' https://stackoverflow.com/a/50145011/18573 Dim sFilter As

Email data exported to Excel - Sort by Received Date

≡放荡痞女 提交于 2019-12-11 08:32:28
问题 I am writting a macro to export email data to excel file for monthly report. However I have realised that the data being pulled out is not accordingly to dates; all jumbled up. Some mailboxes have tons of emails Hence taking efficiency issue in consideration, is there any way to get the data in latest to oldest order? Below is part of the code: Dim msg As Outlook.MailItem Dim nms As Outlook.NameSpace Dim fld As Outlook.MAPIFolder Dim itm As Object 'Select export folder Set nms = Application

Search sent mail and move multiple mail to a folder

风流意气都作罢 提交于 2019-12-11 07:43:29
问题 I try to search the SentMail folder for mail where To address ends with, lets say .cn and move it to a personal folder. The code work but doesn't move all the mail, for every time I run it it's take a few more mail. If I have 24 mails that ends with .cn it takes 13,6,3,2 so in the end it finds all the mail but not on the same run. Anyone have any ideas? Sub Search_SentMail() Dim myOlApp As New Outlook.Application Dim MyNameSpace As Outlook.NameSpace Dim MyInbox As Outlook.MAPIFolder Dim

Issue with Outlook Event for New Mail

China☆狼群 提交于 2019-12-11 07:37:36
问题 I would like to do some operation when a new mail comes to mailbox. For that I am using Item_Add() Event Private Sub myOlItems_ItemAdd(ByVal Item As Object) ... Do Something Exit Sub Can anyone tell me How to set the Handler for "inbox" folder under "gilbertojperera@gmail.com"? Problem: The issue I am facing here is that this even get fired only when a new mail comes in "Inbox" folder under "Outlook Data File". But I used to receive mails in the other "Inbox" folder marked by second red arrow

VBA Copy sent mail to folder based on key words in subject

五迷三道 提交于 2019-12-11 07:35:18
问题 Desired functionality: Whenever I send an email which contains the word XYZ in the subject, I want Outlook to copy that email in the folder XY including the sent-date and marked as read. For now I have found 2 approaches – both not working: Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) If TypeName(Item) <> "MailItem" Then Exit Sub ' ~~> Search for Subject Set ol = New Outlook.Application Set olns = ol.GetNamespace("MAPI") Set myFolder = olns.GetDefaultFolder

Run-time error '-2147221241 (80040107) while running VBA script in Outlook

不打扰是莪最后的温柔 提交于 2019-12-11 07:32:51
问题 I have a VBA script running in Outlook that is supposed to move incoming emails with a specific subject to a subfolder within Outlook, and then export those emails to TXT files. This is working for the most part, but after several emails are exported the message: "Run-time error '-2147221241 (80040107)': The Operation failed." pops up. I debugged it and it is highlighting the line of code: RevdDate = Item.ReceivedTime Once this error appears I can restart Outlook and it will usually export