vba

Running Macro from .bat with another Access db open

微笑、不失礼 提交于 2021-02-10 16:23:12
问题 I need to run a few Access macros automatically periodically throughout the day, I do this by scheduling a batch file to open the relevant Access db and run the macro. The problem that I am having is, if I am working on another Access database and therefore already have an instance of Access open, the batch file runs but only opens the database containing the macro that is supposed to run and stops. So the macro doesn't run. Has anyone else had this issue or know how to solve it? The batch

VBA Loop to fill numbers in a combobox

十年热恋 提交于 2021-02-10 16:20:50
问题 Not sure why this seemingly simple piece of code keeps crashing excel for me: Dim i as Long For i = 0.25 to 10 step 0.25 me.combobox1.addItem (i) Next i Seems pretty straight forward, I want my combobox to have a list that looks as such: 0.25 0.50 0.75 1.00 . . . 10.00 回答1: Shorter version without loop: ComboBox1.List = [text(row(1:40)/4,"0.00")] 回答2: maybe try getting rid of i from "Next i" i.e use only Next instead of Next 1 来源: https://stackoverflow.com/questions/45155642/vba-loop-to-fill

VBA : Change the style of text when sending a mail

荒凉一梦 提交于 2021-02-10 16:02:35
问题 I use Excel to send emails using text in a textbox as body. This works fine, except that when sending a mail, it only copies the text's font size, but not its color or style. I did lots of research, but didn't find any solution. Is there a code that allows Excel to copy the style of the text in a textbox as well as its content? Here is the code of sending the mail : Sub SendMail() Dim OutApp As Outlook.Application Dim OutMail As Outlook.MailItem Dim strbody As String Set OutApp = CreateObject

VBA : Change the style of text when sending a mail

梦想与她 提交于 2021-02-10 16:00:33
问题 I use Excel to send emails using text in a textbox as body. This works fine, except that when sending a mail, it only copies the text's font size, but not its color or style. I did lots of research, but didn't find any solution. Is there a code that allows Excel to copy the style of the text in a textbox as well as its content? Here is the code of sending the mail : Sub SendMail() Dim OutApp As Outlook.Application Dim OutMail As Outlook.MailItem Dim strbody As String Set OutApp = CreateObject

VBA : Change the style of text when sending a mail

我的梦境 提交于 2021-02-10 16:00:11
问题 I use Excel to send emails using text in a textbox as body. This works fine, except that when sending a mail, it only copies the text's font size, but not its color or style. I did lots of research, but didn't find any solution. Is there a code that allows Excel to copy the style of the text in a textbox as well as its content? Here is the code of sending the mail : Sub SendMail() Dim OutApp As Outlook.Application Dim OutMail As Outlook.MailItem Dim strbody As String Set OutApp = CreateObject

Ultimate 1000 separator using VBA

被刻印的时光 ゝ 提交于 2021-02-10 15:39:58
问题 I have been trying to get VBA solution for 1000 separator as in my case it is not possible to use formula and should be done with custom code. Current solution is taken from answer Number Format with Thousands Separator and Decimal if Necessary Here is the code: Function CustomFormat(InputValue As Double) As String CustomFormat = Format(InputValue, "# ###") If (Right(CustomFormat, 1) = ".") Then CustomFormat = Left(CustomFormat, Len(CustomFormat) - 1) End If End Function It is working for

VBA - Copy a template worksheet and rename with user entered text

放肆的年华 提交于 2021-02-10 15:37:26
问题 VBA novice here - I've combed the interwebs and can't seem to get this to work, it's got me stumped. I would like to have a button on a form that will allow a user to generate a copy of a worksheet "Template", in the same workbook - to the right of "Template". I've figured it out enough that I can generate a copy that renames itself as Template(2) OR generate a blank worksheet named with the text entered in the prompt, but I can't do both. As is below - it currently returns an "Object

Sending letter from a specific mailbox

前提是你 提交于 2021-02-10 15:17:24
问题 I want to send a letter via Outlook (using Excel VBA). I need it to be from the department mailbox. Current code looks like this: Dim Outlookwindow As Outlook.Application Dim NewLetter As Outlook.MailItem Set Outlookwindow = New Outlook.Application Set NewLetter = Outlookwindow .CreateItem(olMailItem) With NewLetter .BodyFormat = olFormatHTML .Display .HTMLBody = "Stuff and more stuff" .To = "people" .CC = "more people" .Subject = "About stuff" .Send End With Is there a way to send from the

Sending letter from a specific mailbox

谁都会走 提交于 2021-02-10 15:17:14
问题 I want to send a letter via Outlook (using Excel VBA). I need it to be from the department mailbox. Current code looks like this: Dim Outlookwindow As Outlook.Application Dim NewLetter As Outlook.MailItem Set Outlookwindow = New Outlook.Application Set NewLetter = Outlookwindow .CreateItem(olMailItem) With NewLetter .BodyFormat = olFormatHTML .Display .HTMLBody = "Stuff and more stuff" .To = "people" .CC = "more people" .Subject = "About stuff" .Send End With Is there a way to send from the

Sending letter from a specific mailbox

戏子无情 提交于 2021-02-10 15:16:32
问题 I want to send a letter via Outlook (using Excel VBA). I need it to be from the department mailbox. Current code looks like this: Dim Outlookwindow As Outlook.Application Dim NewLetter As Outlook.MailItem Set Outlookwindow = New Outlook.Application Set NewLetter = Outlookwindow .CreateItem(olMailItem) With NewLetter .BodyFormat = olFormatHTML .Display .HTMLBody = "Stuff and more stuff" .To = "people" .CC = "more people" .Subject = "About stuff" .Send End With Is there a way to send from the