vba

Access sub folder in secondary email account

99封情书 提交于 2021-01-29 14:31:22
问题 I am trying to move emails from the inbox in a secondary Outlook account to a sub-folder in that account. Sub newBox() Dim myInbox As Outlook.Folder Dim myDestFolder As Outlook.Folder Dim myItems As Outlook.Items Dim myItem As Object Dim i As Integer Set myInbox = Session.Folders("Secondary").Folders("Inbox") Set myDestFolder = myInbox.Parent.Folders("Complete") End Sub When I try to set the destination, myDestFolder , I get Run-Time error, An object could not be found. 回答1: You navigated the

How to add Open Workbook to “Application.Workbooks” collection and/or interact with Workbook

北慕城南 提交于 2021-01-29 14:30:16
问题 I have a macro which runs from wb=ThisWorkbook . It opens up Internet Explorer and retrieves another WB which automatically opens. I'm trying to copy the sheet from that WB to ThisWorkbook , but it doesn't appear the "automatically opened" wb's are included in "Application.Workbooks". Can I force an update to "Application.Workbooks" or hack around this limitation somehow? More Details: My macro opens IE, finds a button and presses it which automatically opens a separate instance of Excel

How do I change a Microsoft Word Content Control placeholder text format using a VBA script?

冷暖自知 提交于 2021-01-29 14:28:56
问题 I have created a Microsoft Word Form using interactive Content Controls. It is a really long form with a variety of fields and field types (drop down lists, text boxes, combo boxes, check boxes, etc...) After a couple of months and multiple edits it came back to me with inconsistent formatting of field values and placeholder text values. Some fields stay grayed out even after you fill them out. Other fields have placeholder text that is not grayed out at all. The font seems to have

Why is my script not running automatically when outlook is started?

自古美人都是妖i 提交于 2021-01-29 14:26:22
问题 This script is in ThisOutlookSession and is only running if I change the functions to Public and run the function manually. I am using Outlook 365. This program scans for emails in an Inbox subfolder and when a new email comes in it downloads the attachment and sends it in an email to a different address. Why is it not running automatically and how do I fix it? Option Explicit Private WithEvents Items As Outlook.Items Private Sub Application_Startup() Dim olNs As Outlook.NameSpace Set olNs =

Extracting data from Word to Excel

ε祈祈猫儿з 提交于 2021-01-29 14:09:36
问题 Sub GetFormData() 'Note: this code requires a reference to the Word object model. 'See under the VBE's Tools|References. Application.ScreenUpdating = False Dim wdApp As New Word.Application, wdDoc As Word.Document Dim FmFld As Word.FormField, CCtrl As Word.ContentControl Dim strFolder As String, strFile As String Dim WkSht As Worksheet, i As Long, j As Long strFolder = GetFolder If strFolder = "" Then Exit Sub Set WkSht = ActiveSheet i = WkSht.Cells(WkSht.Rows.Count, 1).End(xlUp).Row 'Disable

Vlookup for an array of values

旧城冷巷雨未停 提交于 2021-01-29 14:02:19
问题 ManagerEmployeeSheet A B 1 manager Employee 2 M1 E1 3 M1 E2 4 M1 E44 5 M1 E41 6 M1 E34 7 M2 E100 8 M2 E17 9 M2 E29 and so on I am making a dynamic dashboard where I need the employees under each manager to be dynamically reflected. DashboardSheet A B 1 Input Manager M1 #basically user inputs one manager name here in this cell 2 E1 3 E2 4 E44 5 E41 6 E34 So when I input M1 manager in cell B1 of DashboardSheet , I should get all employees under him in below cells, similarly if I input any other

Remove words from a cell that aren't in a list

你离开我真会死。 提交于 2021-01-29 13:14:49
问题 I want to remove some words that aren't in a separate list from an excel list. Someone gave me an example with Find/Replace, but i need the exact opposite, meaning that i want to keep the words in the list and remove the other. Also if a word is removed, I would have more than 1 space so i would need to remove multiple spaces. Can anyone give me an example? Thanks, Sebastian EDIT Initial cell contents: word1 word2 word3 word4 Cell contents after script: word2 word4 My list contains: word2,

Is there a way to save macro script into a variable as string in Visual Basic?

淺唱寂寞╮ 提交于 2021-01-29 13:05:28
问题 I want to write certain macro script in a cell as text. Googled, but I found nothing. 回答1: You could export your module to a file: ThisWorkbook.VBProject.VBComponents(Module.name).Export ModuleFile Then read that file in to a variable. Parse it, and do whatever you want with the text at that point. This requires programmatic access to VBA, which as @GSerg points out is a terrible idea. It opens you up to malware VBA code attacks. 来源: https://stackoverflow.com/questions/57526534/is-there-a-way

VBA code to check and create folder system and save file

对着背影说爱祢 提交于 2021-01-29 13:00:16
问题 I'm looking to create a code that takes an active worksheet which once completed and a button is selected it saves it as a new workbook within a folder / subfolder system based on multiple cell values. Some of the cells may stay the same but others may change, giving a variety of potential paths which could already part exist or not exist at all. I've managed to put a code together which does just that but when I change one of the cell values, which ultimately changes the path slightly, I get

Using Excel VBA, how to search for a specific word and insert comments against that word in a Word document?

混江龙づ霸主 提交于 2021-01-29 12:51:58
问题 I am trying to create an excel based tool that reviews Word documents for specific errors. I want this tool to search for a word/sentence and insert a comment against it. I have written a code (please see below) that is able to highlight the word/sentence, however, unable to insert the comment. Here is my code so far: Sub Ref_Figs_Tbls() Dim wdDoc As Object Set wdDoc = ActiveDocument With wdDoc With .Range With .Find .ClearFormatting .Replacement.ClearFormatting .MatchWildcards = True .Wrap =