vba

Excel VBA: Passing a collection from a class to a module issue

Hello, I have been trying to return a collection from a property within a class to a routine in a normal module. The issue I am experiencing is that the collection is getting populated correctly within the property in the class (FetchAll) but when I pass the collection back to the module (Test) all the entries are populated with the las...

How to (programmatically) figure out the path of the current ArcMap document with VBA

Hi, I would like a Visual Basic for Application Function which shows the path of the current document. For example if ArcMap is displaying map.mxd I need to display its path. I found only some examples for querying the path of the datasources of the displayed layers. ...

Automating Excel through the PIA makes VBA go squiffy.

I have absolutely no idea how to start diagnosing this, and just wondered if anyone had any suggestions. I'm generating an Excel spreadsheet by calling some Macros from a C# application, and during the generation process it somehow breaks. I've got a VBA class containing all of my logging/error-handling logic, which I instantiate using a...

How can I find the number of highlighted chunks of text in an MS Word Document

Hi all, I am writing a macro in MS Word which should find all highlighted text in a document and perform some action on each. I am planning a loop to do the search and manipulation part and have no problem with this portion of the code. But I don't know how to find how many iterations I'm going to need. Is there a way to determine the nu...

I need to Loop an a formula with the Offset function until the cell is blank

I need to Loop the formula below until Column "B" which contains dates is empty. I am stuck and I just can't seem to write the VBA Code to do the Loop until there is no more Dates in Column "B". The formula is smoothing out the yields by using those dates that have a yield. I hope anyone would be able to help me. Thanks in advance ...

Access VBA sub with form as parameter doesn't alter the form

I have a Microsoft Access 2003 file with various tables of data. Each table also has a duplicate of it, with the name '[original table name]_working'. Depending on the user's choices in the switchboard, the form the user choose to view must switch its recordsource table to the working table. I refactored the relevant code to do such a...

Repurpose builtin Word commands - access original command within repurposed function

It is possible to repurpose a Word builtin command in Word 2007 using the customUI.xml file. Example: <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"&gt; <commands> <command idMso="Save" onAction="MySave"/> </commands> </customUI> I then have to define a callback function in VBA which is used ins...

Populating Specific Cells Using VBA

I am using VBA to pull from a SQL table and it automatically populates cell E14. Not sure why it's that cell, but is there a way to specify which cell it pulls the data into? Here's what I have right now: strSQL = "SELECT distinct Source FROM dbo.Simulations WHERE SimulationID = 5 ...

How do I display a message when clicking on an object in Visio using VBA?

I'm totally new on this so I want to start with something simple. I have just an object in my Visio document and I want to display a Hello World! message whenever it's clicked. ...

Export sheet from Excel to CSV

I am creating a spread sheet to help ease the entry of data into one of our systems. They are entering inventory items into this spread sheet to calculate the unit cost of the item (item cost + tax + S&H). The software we purchased cannot do this. Aan invoice can have one or more lines (duh!) and I calculate the final unit cost. This is...

Merge Multple Worksheets From Multple Workbooks

Hi, I have found multiple posts on merging data but I am still running into some problems. I have multiple files with multiple sheets. Example 2007-01.xls...2007-12.xls in each of these files are daily data on sheets labeled 01, 02, 03 ..... There are other sheets in the file so I can't just loop through all worksheets. I need to combin...

What is VBA good for?

Besides making macros, what is VBA good for? I'm in an intro programming class for Engineering, and I don't really see any use for it. ...

WHERE IN Query with two recordsets in Access VBA

Hi All, My first post here, so i hope this is the right area. I am currently trying to compare 2 recordsets, one of which has come from an Excel named range, and the other from a table in the Access database. The code for each is: Set existingUserIDs = db.OpenRecordset("SELECT Username FROM UserData") Set IDsToImport = exceldb.OpenReco...

What is the maximum number of controls that a VBA form can hold?

I'm currently building an Excel 2003 app that requires a horribly complex form and am worried about limitations on the number of controls. It currently has 154 controls (counted using Me.Controls.Count - this should be accurate, right?) but is probably only about a third complete. The workflow really fits a single form, but I guess I c...

Problem with VBA app after office 2007 was installed

Ever since we installed Office 2007, our VBA apps code stopped working. When I debug, I get a compile error and .edit is highlighted. I replaced the .edit with .update and i don't get any debug errors, but when i run the code i get a type mismatch error code. Is the something im doing wrong? Here is the codez: Private Sub Command290...

Dynamically Populate Listbox - Exclude Empty cells

I am creating a form in excel (not a userform) and I am populating the listbox using cells. However, these cells are sometimes A1:10 and sometimes they are A1:A4. Is there a way to dynamically change what is shown in the listbox? Right now, when I use A1:10 and there are only 4 cells populated, I get the list of 4 populated cells follow...

ACCESS.Visual basic. Make treeView object

I have a database(3 tables). I want to build treeView. I don't know how to create recordset and how to retrieve record from it. ...

Calling a Sub or Function contained in a module using "CallByName" in VB/VBA

It is easy to call a function inside a classModule using CallByName How about functions inside standard module? ''#inside class module ''#classModule name: clsExample Function classFunc1() MsgBox "I'm class module 1" End Function ''# ''#inside standard module ''#Module name: module1 Function Func1() MsgBox "I'm standard...

Why is it not possible to call RegFree COM and .NET from the VB IDE (VB6 & VBA)?

Hi I have an example project with works when called from compiled VB6 but not from the IDE or from Excel's VBE. There are 3 DLLs QA.DLL, QB.DLL, QAW.DLL. QA is written in C#.NET, QB and QAW are written in VB6. QAW is a COM wrapper of QA. In the calling code I create an Activation Context and load a manifest file. All works fine from...

how do i set a value to a range using a function from module in excel vba?

hello all, i want to do a simple function in a module in excel vba, so i can use it as a custom function in excel. (i use excel 2003, or 2007 , it's doesnt matter) i create a function(!) in a new workbook and it's looks like this: Function a() Sheets(1).Range("A1").Value = 4 end function but when i try to use it on the sheet1 it...