Click here to Skip to main content
15,891,657 members
Everything / Macros

Macros

macros

Great Reads

by GProssliner
cobj is a preprocessor based generator for interface based polymorphism
by LukeCodes
This is a simple macro script to search and retrieve individual cells in an Excel document.
by Liju Sankar
Read Loud Email Sender and Subject as soon as you received an email in OUTLOOK
by Sachin Chandanshive
Read / Write data from CSV to Excel

Latest Articles

by Patrice T
The Excel Tools I crafted to simplify my life as programmer
by kurta999
Automotive development tools and other things
by RegularJoe5150
An alternative solution to a standard macro that aims to make macros, just a little bit less evil
by Alexander Schichmanter
Concept, Motivation and Implementation of Dynamic Logging - a valuable aid to the C++ programmer

All Articles

Sort by Score

Macros 

7 Jun 2016 by GProssliner
cobj is a preprocessor based generator for interface based polymorphism
12 Jun 2017 by LukeCodes
This is a simple macro script to search and retrieve individual cells in an Excel document.
2 Dec 2012 by Espen Harlinn
First:// Better, but still, no.. (Having to supply the type really brings it down.)Vector::Erase(numbers, 200); // See below for codeVector::Erase(numbers, 200); //
3 Dec 2012 by Stefan_Lang
While there are exceptions in favor of using macros, the examples you've given are a definitive NO-GO! Here are the reasons:1. Macros pollute the global namespace: if you intend to use them locally (i. e. within just one cpp unit), then neither the readability nor the safed time for typing...
29 Nov 2013 by Sergey Vaselenko
Hello,You may use the following formula on a worksheet:=NOT(ISERROR(MATCH("*";$A$1:$A$10;0)))But, "~" must be specified as "~~". For example:=NOT(ISERROR(MATCH("~~";$A$1:$A$10;0)))VBA functions:Function MyMatch(ByVal lookup_value As Variant, ByVal lookup_range As Variant)...
17 Jan 2015 by Liju Sankar
Read Loud Email Sender and Subject as soon as you received an email in OUTLOOK
5 Apr 2011 by Slacker007
I don't think you can "import" a macro from another document into a separate document on the fly.I could be off based here but don't you want to create a Word Template with the macro in this template and then when you create a new Word Doc (through your C# code) based on this new template.
16 Mar 2012 by Sachin Chandanshive
Read / Write data from CSV to Excel
10 Apr 2012 by Cale Dunlap
C/C++ pre-processor macros which I have found to be quite useful, so I decided to share them. I hope they help you as much as they've helped me.
13 Aug 2012 by Sachin Chandanshive
Addin Containg Useful Macros & Easily Accessible From Ribbon Menu
15 Jul 2012 by Prasad_Kulkarni
You need to ask this question in proper forum to get quick and accurate guidelines as well as response.Article Writing[^] is the forum where this question belongs.And remember if you got any problems or issues while submitting your article then post your query on Site bugs and...
1 May 2014 by Maciej Los
The error meassage says exactly what is wrong! The data from subquery are not related with main query and return more then 1 record!Using too many subqueries to produce columns could be the reason of application crash or performance issue at least.Redesign your query! Start with basics:...
9 Jun 2016 by Patrice T
You should try to replace all ActiveWorkbook.Worksheets("JUN16") with ActiveSheet.Application.ActiveSheet Property (Excel)[^]
19 Feb 2018 by OriginalGriff
Because it's a number - and unless the column is formatted as Text, or the number is preceded by a quote, Excel will treat it as a number. And numbers do not have leading zeros... Prefix the first 0 with a quote and Excel should treat it as text.
23 May 2023 by kurta999
Automotive development tools and other things
6 Dec 2009 by Ashish Sheth
Invoking Google from within VS 2008
4 Apr 2011 by mpower88
I have this situation:I made an add-in for Word 2010 in visual studio 2010 (C#), which dynamicly adds new buttons to a new ribbon tab (data from sql database). Now when i click on a button, a new document with a macro needs to be opend. I have the needed macro in a document (.docm), and the...
15 Jun 2011 by jabit
The default FormView template has no structure. Use this Visual Studio macro to format templates as tables.
17 May 2011 by HimanshuJoshi
Yes, here [^]is a video tutorial that explains how to do it.
10 Jun 2011 by S Houghtelin
You had me confused when you said at compile time, this would mean a build directive, then you would need to create a variable or object with data binding to check for the number of compile times.If you meant to count number of times a function is accessed during run time, you have(at the...
10 Jun 2011 by Sergey Alexandrovich Kryukov
Sorry that my answer is not about C++, but my idea is so unusual and universal so it could be interesting for you.My solution is well implemented and tested; and I know for sure you can use this idea, because from in C++ you always can look at the stack and remember the calling...
16 Aug 2011 by Bangla Gopal Surya Prakash
Hi Guys,I have window application running & this application has a form with a TextBox.And I want to build a Word 2007 Macro, Which will pass string from Macro to the running Windows Application & place it in TextBoxPlease help me with this regard.Thanks & Regards,Prakash
26 Aug 2011 by AlexCode
Quick way of showing the Solution check-in modal window on Visual Studio
16 Oct 2012 by Maciej Los
Like this:Dim wsh As WorksheetDim rng As RangeSet wsh = ActiveWorkbook.Sheets("clients")Set rng = wsh.Range("A1")'your code...'and after allSet rng = NothingSet wsh = Nothing
14 Apr 2013 by Sergey Alexandrovich Kryukov
Yes, this is achievable, but this is quite a big work. Reflection won't help much, because it works with compiled assemblies or assemblies created during runtime, but refactoring has to work with source code.Is there available classes? It actually depends on available compilers. There are...
25 Apr 2013 by Maciej Los
Change your scenario ;) and import data to Access from Excel using Access database. It's easiest way.Import Excel data to an Access database[^]Import, export, and link data between Access and Excel[^]vba - Import Excel data in Access[^]But if you want to use Excel, please provide...
10 May 2013 by Maciej Los
I do not understand you... If you don't want to use formula, why are you asking about which is better: macro or formula? If you want to enumerate / list employees from the top of the second workbook/worksheet, because you don't want to sort data on formula column, you need to use VBA code...
1 Jul 2013 by Maciej Los
Here is a question on Stack Overflow[^]. And the answer is:Jon Fournier May 31 at 16:23 wrote:If I were you I would instead set up outlook to sync your gmail account, and use the outlook API. It is probably at least 10x easier that way.Posted to remove above question from "Unanswered...
2 Jul 2013 by Fredrik Bornander
First of all, the input data doesn't seem to match your expected output data; you only have Item1s in the input data, and it only maps to ItemRoute1 so I can't see how you could get more than one Procurement and one Selling line from that input.But, having said that, I think something like...
3 Jul 2013 by Maciej Los
The fastest way to achieve that is to use ADODB[^] with Dictionary[^] object.More:Using ADO with Excel Data Sources[^]How To Use ADO.NET to Retrieve and Modify Records in an Excel Workbook With Visual Basic .NET[^]Reading an Excel spreadsheet using ADO.NET[^]How To Use the Dictionary...
10 Aug 2013 by Maciej Los
Have a look here: Hyperlinks.Add Method (Excel)[^]
3 Dec 2013 by Maciej Los
Please, read my comment first.There are several resons why not to insert macros in normal template. The most important is security. Please, see this: Working with Microsoft Word Templates—The Foundation[^]As i mentioned, the simplest method is to replace normal.dot (using for example zip...
13 Apr 2014 by Manas Bhardwaj
Did you know that at CodeProject, people help eachother when there are facing problems and not work for them.Simplest way for you to is GetACoder[^]
14 Dec 2014 by Maciej Los
MS Word differs from Excel. Adding a context menu is a bit more complicated, because we need to create custom class to be able to "manage" right-click event.Steps to do:Go to the VBACode editor (ALT+F11)Insert new class module and change its name to: cRightClickEventHandler. Copy and...
17 Dec 2014 by Maciej Los
Steps to do:Loop through the collection of paragraphsCheck if paragraph contains searched string if contains, skip to next paragraph if not, deleteSample code:Option ExplicitSub SearchAndDestroy()Dim p As ParagraphDim searchedText As StringOn Error GoTo...
19 Dec 2014 by Maciej Los
By default all userforms are opened as modal window. To open UserForm in modeless mode, use:UserForm1.Show vbModelessPlease, see: Show Method[^]
16 Jan 2015 by deepakdynamite
You cannot do this directly in SSRS. but there is a work around if you wish to proceed.1. generate your files in folder.2. create SSIS Package and add script task.3. write C# code to program your needs on each file.oExcel = CreateObject("Excel.Application")oExcel.Visible =...
17 Feb 2015 by CHill60
I personally would not choose to process such large files with VBA - as you have hinted I would pre-process the text file (I would use C# as my preference) to produce a CSV file that could then just be loaded directly into Excel.However, you have tagged VBA and you have also said that you...
25 Mar 2015 by Sergey Alexandrovich Kryukov
Excel files can use open format based on Open XML standard, but it has nothing to do with W3 standards and is foreign to the Web.There is no such concept as "embedding". You can simply store Excel and other office files on the server. To present them, you have to use HTML. You can develop...
13 May 2015 by bling
Don't use macros for this. Use __inline for inline expansion of the called function.For variable arguments, you may need to define multiple overloads - to match your varying needs.We could offer more specific advice if you post your code.
20 Aug 2015 by Maciej Los
I'll improve your code to 3 lines:ActiveSheet.UnprotectActiveCell.EntireRow.Delete Shift:=xlShiftUpActiveSheet.Protect ...For further information, please see: Range.Delete Method (Excel)[^]Note: your code is potentially dangerous, because it works no matter of context! What it...
1 Sep 2015 by Maciej Los
If i understand you well...All what you need to do is to pass path to ms Access database as an argument:Sub Mail_workbook_Outlook_2(ByVal sDatabaseFile As String)'newcon.Open "provider=microsoft.ace.oledb.12.0;Data source= " & sDatabaseFile'End SubUsage:Sub WhateverDim...
6 Nov 2015 by Maciej Los
Above code refers to Microsoft Office Excel BeforeSave event, but you mentioned that you use OpenOffice Calc!See:Using a Global Library to Automate OOo Calc[^]Document Events[^]Creating a simple macro[^]Google book: Using Spreadsheets in OpenOffice.org 3.3[^]
11 Jan 2016 by Sergey Alexandrovich Kryukov
According to this Wikipedia page,Code written in VBA is compiled to a proprietary intermediate language called P-code (packed code), which the hosting applications (Access, Excel, Word, Outlook, and PowerPoint) store as a separate stream in COM Structured Storage files (e.g., .docx or .xlsx)...
3 Mar 2016 by CHill60
You can write some VBA to list all of the macros in your worksheet - see this link Generating a List of Macros (Microsoft Excel)[^]. As well as the reference given you will need to have a reference to "Microsoft Visual Basic For Applications Extensibility Library".In theory you can do...
17 Aug 2016 by Maciej Los
Well...I hate to provide ready-to-use solution, but tonight i'm gonna to make an exception ;)Option ExplicitSub SortAndExportData() Dim wbk As Workbook Dim srcwsh As Worksheet, dstwsh As Worksheet Dim rangeToSort As Range Dim i As Integer, r As Integer, c As...
9 May 2017 by Maciej Los
Please, read my comment to the question first. The comment to the solution #1 provided by CHill60[^] will be helpful too. Let's say you want to write 10 random numbers in Sheet1 but you want to get minimal and maximal values to randomize from Sheet2. Take a look at example: 'force explicit...
27 Feb 2018 by Maciej Los
Assuming that data are stored in columns A-D and starts from row 2 (forst row = headers), check this: Option Explicit Sub ExplodedDataToTable() Dim srcWsh As Worksheet Dim i As Long, r As Long On Error GoTo Err_ExplodedDataToTable Set srcWsh = ThisWorkbook.Worksheets(1) 'you can...
22 Jan 2019 by Richard MacCutchan
macro convert dob to text msword - Google Search[^]
13 Mar 2019 by Patrice T
Quote: Excel VBA vlookup with multiple results VLookup with "multiple results" does not exist. I think you need to create appropriate VBA program. As far as I understand what you want, you have a list: Report Title | Emails Report One | Emailone@email.com,Emailtwo@email.com Report Two |...
14 Mar 2019 by Maciej Los
Try this: Option Explicit Sub SplitEmails() Dim srcWsh As Worksheet, dstWsh As Worksheet Dim i As Long, j As Long, k As Long Dim emails() As String On Error GoTo Err_SplitEmails Set srcWsh = ThisWorkbook.Worksheets(1) 'replace 1 with corresponding sheet name, for ex.:...
25 Mar 2019 by Maciej Los
Assuming that a worksheet #1 contains the data listed below, started from A1 cell: ID Property Value 1234 Color Blue 1234 Width 1.5" 1234 Supplier XYX 1235 Color Orange 1235 Width 3.5" 1235 Supplier ZZA and you want to achieve something like that (in a #2 worksheet): ID Color Width Supplier...
2 Dec 2019 by CHill60
Your question is not entirely clear, but I can tell you not to use Paste! Have a look at this code snippet...Public Sub test() Dim SourceRange As Range, TargetRange As Range Set SourceRange = ThisWorkbook.Sheets(1).UsedRange Set TargetRange =...
16 Mar 2020 by Maciej Los
You can disable it, but i do NOT recommend to do that! See: Enable or disable security alerts on the Message Bar - Office Support[^] Enable or disable macros in Office files - Office Support[^] If you have any macro to made some calculation,...
4 May 2021 by CHill60
Unlike most other Microsoft Office Applications, running a macro on the Open event is not straightforward in PowerPoint. You can - download one of the many Add-Ins that can facilitate this - or do some fancy tricks with a Custom UI component -...
21 Dec 2021 by CHill60
I used to do this. 1. Write some VBA to read the contents of a text file into a table. There are many examples on the internet e.g. VBA procedure to import csv file into access[^] 2. Write another VBA function to list the files in the folder...
18 Mar 2022 by CHill60
Can I suggest that you break the problem down. Here is some sample data that I set up Row SLA Name Month Met/Not Met 1 Item 1 2022-01 Not Met 2 Item 1 2022-02 Not Met 3 Item 1 2022-03 Not Met 4 Item 2 2022-01 Not Met 5 Item 2 ...
9 Oct 2023 by OriginalGriff
To the best of my knowledge, you can't do anything about this from your end: MS blocks macros in downloaded files as a security measure, and only the user can override that (as you would expect, if you could override that it wouldn't provide any...
16 Dec 2009 by nijuniro
Hi,I've just got stuck on some problems with CommandEvents, but I managed to find that solution:http://www.dotnetmonster.com/Uwe/Forum.aspx/vs-ext/623/DTE-CommandEvents-handlers-not-working-reliably[^]It says that you must keep the reference for CommandEvents object. It did the trick for...
25 Mar 2010 by Christian Graus
Given that there's a command built in, I assume this is homework. I've written an article on how bicubic interpolation works, perhaps that's a good starting point for you to learn how it works to do your own homework ?
25 Aug 2010 by GangadharMG
Dear all,I am writing Excel macros for an application using Excel 2003.I could see the code window supports only VB6 coding styles.Is there any way to write the code in VB.NET within that Excel macro?Please let me know if you have any suggestions.Thanks & regards,M. Gangadhar.
25 Aug 2010 by Dalek Dave
Yes.Ish....
26 Aug 2010 by GangadharMG
Hi,Thanks for the reply. Do you mean that we are writing a VB.Net library (.DLL) and referencing/calling the functions inside VBA macro?Is there direct code editor window for VB.Net available for VBA macro - or any additional utilities to be installed?With Thanks & Regards,M. Gangadhar.
28 Aug 2010 by weylspinor
I figured it out. You have to do: #include
18 Sep 2010 by ErnestoNet
How to join the parts of a file across several mails in MIME / Base 64 format in outlook
6 Dec 2010 by ErrolErrol
Thank you, in advance, for any assistance that you may lend. I am using the voice recognition software found in Windows 7. I am also using the additional macro recognition software from MS. An example of usage would be: I utter the word "foobar" and instead of typing those characters on my page,...
8 Dec 2010 by ErrolErrol
Hi Me! First things first. I really want to thank the 49 people that took a look at my question, shrugged and headed off to do something worth their time. I do appreciate very much the moments of your lives that you spent trying to help me.It turns out that I should have been trying...
15 Dec 2010 by imdarklord
Hi All, I wish to execute an excel with macros using ASP.NET 2.0 and C#. I tried using interop services and was able to execute in my local system but unable to do so in server. Then I created a console application to open the excel containing macros and again I was able to do in...
15 Dec 2010 by Dylan Morley
It's difficult to say without seeing all of the Macro code (which is probably where the error is occurring)However, the fact that it's working locally and giving a 'file not found error' on the server makes me think you are using directory locations \ path strings in the Macro that don't...
22 Feb 2011 by Abhinav S
I did a search and yes this appears to be possible.Found a tip here[^].
8 Apr 2011 by Srinivas39
Hello Guys,I created an MS Word Addin. for which i want to install with macros dynamically in my program.Can any one tell me how i can install addin with macros?Thanks in advance.Regards,Srinivas
8 Apr 2011 by #realJSOP
"Macros" aren't available in .Net...
14 Apr 2011 by Srinivas39
Hi Guys,I created an MS Word 2007 Addin and i want to convert it to a Macro, is there any facility to convert it to a macro?Can i install the Addin to a selected Word Doc and not to all the word docs? If it can be done, please tell me the way to get that done?Thanks in...
14 Apr 2011 by Slacker007
What language did you create your Addin in? There is no way that I know of to easily convert VB.Net or C# to a VBA macro. You will have to do it line by line. I don't think you can install the addin to an individual Word doc. You install the addin to MS Word itself not to an individual .docx...
6 Jun 2011 by Member 7984620
Hi, I want to create a template with below conditions. Please help me on a code that would perform the below actions. I dunno VB as am from a commerce background. I tried my best with the hlp options, but unable to suceed. Kindly help me.1) There should be two command button, 1) Start time &...
6 Jun 2011 by Simon_Whale
assuming you are talking about MS Office macros I would start by having a look here VSTO Developer Centre[^]
6 Jun 2011 by walterhevedeich
We can certainly are capable of helping you with your problem but sad to say were not doing the code for you. The help we can provide here is to help you solve issues that you will meet while creating the program. My advise is for you get a book and start learning VBA programming.
10 Jun 2011 by Wh0p
Tank all of you for the fast response!But I still would like the compiler to check for the first function call not the function itself, so the desired compiler behaviour would be like:"this would mean a build directive, then you would need to create a variable or object with data binding...
23 Jun 2011 by Uros Calakovic
wdDialogFileOp...
10 Aug 2011 by Soft009
Hi.My problem is...I have Access database. and I create access forms to add data to the tables.In my case table1 have combobox. This combobox contain two value (IN, OUT)If we select combobox value as IN then I need to update table2 column value.how can i do this using macro or...
7 Jun 2020 by Soft009
Hi all,I got this error when call the button click event in the ms access VBA.The expression OnClick you entered as the event property setting produced the following error: The expression you entered has a name that Microsoft Office cannot find. * The expression may not result in the...
12 Aug 2011 by Ajain A K
I want to copy data in one sheet of workbook to another I want to generate a new workbook based on sheet of data in another workbook. How record or use I use macro to do this task, for reference I am attaching the excel sheet please have a look. The excel sheet is site.xlsx, this work...
12 Aug 2011 by Richard MacCutchan
I just tried a macro recording session and it worked fine giving me:Sheets("Location").SelectSheets("Location").CopyActiveWorkbook.SaveAs Filename:="yourpath\Book2.xls", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False,...
9 Sep 2011 by Rakesh Meel
Look at bellowing link...http://www.officeletter.com/favtips/wordmacros.html[^]
19 Dec 2011 by WebBiscuit
From the header declaration, this macro opens up the .cpp file and creates the skeleton so you can begin to add the implementation. This makes adding functions a breeze, so now there really is no excuse for having horribly unfactored code.
23 Jan 2012 by bradyguy
Visio Macro that displays the direct and indirect counts of subordinates in an Organization Chart.
3 Mar 2012 by nigam.anant
Hi Every1,I Created a 'Sample.Dll' and 'sample.tlb' file containing a function which returns a value, using Visual Studio 2005 class library for access it in the Microsoft Office Excel's Macro to getting a cells value.I Set some properties in visual studio 2005 before building the...
3 Mar 2012 by nortee
Hi,Have you tried moving the files (on the offending machine) to where the excel exe is? I've gone through DLL hell before and usually it's a case of the application not 'finding' the DLL (even when you put the DLL in the system32 folder).The reason why it would work on the machine that...
27 Jul 2012 by Kenneth Haugland
Seems to be a known problem:http://forums.adobe.com/thread/758213[^]
17 Sep 2012 by Maciej Los
No, you don't need any script...How to customize toolbars and menus in Outlook 2002 and in Outlook 2003[^]http://office.microsoft.com/en-us/outlook-help/create-and-rename-custom-toolbar-HP001234185.aspx#BM4[^]...but - of course - you can do it...
15 Oct 2012 by Jefferson Daniel
Hello I plan on using the code below alot. Application.Goto (ActiveWorkbook.Sheets("clients").Range(""))Instead of writing the ActiveWorkbook.Sheets("") alot how do I make this as a variable. I tried just doing a Dim variable as string = that. But it gave me an error. Is there a...
22 Oct 2012 by aksh619
i am working on a macro that will transfer the data from multiple workbook files with differents worksheets to one work book with 2 worksheet Example Like i have 3 workbooks as (A)sales order with coulmn (1.)orderno (2.) orderdate (3.)shipto (B) shipment ...
22 Oct 2012 by aksh619
i am creating a macro that transfer data from one workbook to another. i am getting a error please help. i have taken command button on workbook on b.xls which will run this.Private Sub CommandButton1_Click()Dim wkb1 As WorkbookDim wknm As Stringwknm = "d:\a.xlsx";Set wkb1 =...
22 Oct 2012 by Richard MacCutchan
One of the easiest way to learn VBA functions quickly is to use the Macro record feature of Excel thus:Select Tools -> Macro -> Record New Macro from the menu.Perform whatever functions you need in your workbooks/sheets.Press the stop recording button.Open the new macro in the editor...
24 Oct 2012 by aksh619
what i want to do is here.. i want to take B2 cell value from Workbook Wkb2 And match it with the other workbook wkb3 and if it is not present there than append that that coulmn value ata the end of the work book . Please some one help me out Also giving error on select2 =...
25 Oct 2012 by aksh619
This code works fine but only for single value . But i want to apply for every coulmn cells like A1 Coulmn cells Set wkb3 = Workbooks.Open(wknm2) For i = 2 To 100 For j = 2 To 100 select2 = wkb3.Sheets("Sheet2").Range("A2").Value Set wkb2 = Workbooks.Open(wknm1) select1 =...
25 Oct 2012 by aksh619
i want to find the last empty row for a particular coulmn like A coulmn . sub abc()iRow = wkb1.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).RowEnd Sub as this is taking only first coulmn and providing me with Irow = 2 but there is data present on second B coulmn ....
31 Oct 2012 by aksh619
its giving error on irowtro error is out of range please help me Sub transferorderdata()Dim wkbor, wkbvl, wkbysd, wkbtr As WorkbookDim wknm, wknm1, wknm2 As Stringwknm2 = "C:\vbproject\tracker\ysdflow2.xlsx"wknm = "d:\a.xlsx" '-------Open orderwknm1 = "d:\SAMPLE.xlsx"...
1 Nov 2012 by aksh619
i am developing a macro which will first transfer and remove. i am using concatenated fields someone help me .. Option ExplicitSub transferorderdata()Dim wkbor, wkbvl, wkbysd, wkbtr As WorkbookDim wknm, wknm1, wknm2 As Stringwknm2 = "C:\vbproject\tracker\ysdflow2.xlsx"wknm =...