vba

Writing to stdout from within a Microsoft VBA macro

I'm using Python (and the Win32 extensions) to execute macros in an Excel spreadsheet via the COM interface, as shown below: import win32com.client o = win32com.client.Dispatch("Excel.Application") o.Visible = 1 o.Workbooks.Open (r"C:\test.xls") o.Application.Run("macro1") What I'd like to do is have the Excel macro output text warnin...

Iterating through the Object Browser in VBA

I would like to iterate through members of any class in a referenced library much like is done using the Object Browser. How can this be done using VBA? ...

What event fires if Excel VBA code execution is prematurely ended?

Is there an Excel Application or Workbook event that fires if code execution is ended from a run-time error? I use Application.Interactive = False at the beginning of some of my procedures. If the code execution stops before Application.Interactive = True at the end of the procedure, then the user gets locked out of the Excel. I don't ...

How to get the excel file name / path in VBA

Say, I'm writing a VBA inside my excel file sample.xls. Now I want to get the full path of sample.xls in my VBA. How do I do it? ...

Why can't the VBA Me keyword access private procedures in its own module?

I just discovered that the Me keyword cannot access private procedures even when they are inside its own class model. Take the following code in Class1: Private Sub Message() Debug.Print "Some private procedure." End Sub Public Sub DoSomething() Me.Message End Sub This code instantiates an instance of the class: Sub TestCla...

Is this the RegEx for matching any cell reference in an Excel formula?

I have been trying to create a regular expressions pattern that matches any reference in any Excel formula, including absolute, relative, and external references. I need to return the entire reference, including the worksheet and workbook name. I haven't been able to find exhaustive documentation about Excel A1-notation, but with a lot...

Optimize SQL SELECT for 4000 searches, into Excel by VBA

How could this be optimized for speed by batching or other techniques? Its a 20MB Access2003 Database I am searching from Excel 2003 VBA. I have my Access Table Keyed (autonumber) so I though this would provide intelligent non-linear searching like binary searches. Currently searching for 4000 values from a table of 147k records is ta...

Max and Min Time query

how to show max time in first row and min time in second row for access using vb6 ...

MS Access 2003 - Customized Auto-Number IDs for tables?

Is there a way to use my own number in a table like an auto-number; that is to automatically assign the next available to a new record. We have system ID numbers for each employee that I want to tie into this database. I just want the table to auto assign the next number. Can I do this? Could this be done with a mixture of numeric and a...

Side-By-Side COM Interop with C# and VBA

I'm not talking about calling a VBA COM from C#... the other way around! What I would like to do is call a C# library using VBA in MS Access without registering the DLL. I've been playing around with side-by-side interop for a while without success and it has finally occurred to me that a mdb.manifest is probably not an acceptable repla...

Is it possible to request temporary trusted access to VBA project object model?

I need to access the VBA code of Office documents (Excel workbooks, but it's not relevant) through .Net / C#. I know how to do this, but this requires the Office user to have granted trusted access to the VBA project object model through the Office app. This makes me uncomfortable, because there is a risk that the user leaves things set ...

Locked Classes with VBA/VB

I want to package my classes (in VBA or VB), but I want to put a lock on them before I do so. I want the computer to return a message similar to one in the Word file attached. Can anybody point me in the right direction? There doesn’t seem to be a lot of help in this regard. I would need something that would lock just the classes that I...

Moving images between cells in VBA

Hello guys, I have an image in cell (3,1) and would like to move the image into cell (1,1). I have this code: ActiveSheet.Cells(1, 1).Value = ActiveSheet.Cells(3, 1).Value ActiveSheet.Cells(3, 1).Value = "" However, it seems that the cell value is empty for cells containing images, so therefore the image is not moved and the image ...

IFileOpenDialog and IFileSaveDialog from VBA

How do you call IFileOpenDialog and IFileSaveDialog from VBA? According to Microsoft, applications written for Windows 7 and later should use IFileOpenDialog/IFileSaveDialog API calls instead of GetOpenFileName/GetSaveFileName (see Using the Common File Dialog). This is especially important for full Library support. ...

How to communicate between two instances of open MDB with same form?

In VBA (Access 2000) is there anyway to send information to a form between two open instances of the database? For example : User 1 has an instance open of DB.MDB on his PC and has FormOne open. User 2 has another instance of DB.MDB open on her PC and has FormOne open. Can User 1 maniuplate the contents of a textbox on User 2's FormO...

How do I concatenate html as a string in VBA?

I'm a newbie at VBA and html and I'm getting very confused. I'm trying to set a string variable to equal several concatenated html strings and control values. I can't figure out what I'm doing wrong. Here is my code: htmlText = "<HTML><BODY bgcolor=#0b3767> <img height=""71"" width=""500"" alt=""Central Analysis Bureau, Inc. - Kno...

Generate a blank table on form check in Word 2003

In Word 2003, I am trying to create a form that can generate additional entries if the person filling out the forms requires them and clicks a checkbox stating (for additional tables click here). I have tried a form field that runs a macro on entry but that does not seem to be working. Is there a more elegant way to make a form that can ...

If an onfocus event handler is added with attachEvent, how can I access it?

Background: I'm writing a script (in VBA, if that matters) to input data into a web-based system. Some of the system's validation is only run when a field is focused, so I've been calling .Focus on the fields in VBA to force it to run. But that steals the systemwide focus; rather annoying if I am doing anything else while the job is run...

object array or collection in VBA Excel

i would like to have an array of objects in excel that call one event handler. specifically I have multiple buttons which perform the same function to different cells, and to keep from duplicating code I would like to simply reference these button objects via an index (like I used to do in VB 6.0).... by finding which button was clicke...

Excel: Putting together two different complex formulas (Unique distinct list & Split)

Hello all you amazing people I wanted to do two things populate a unique distinct list from a long list of repetitive values extract component of a text delimited with hyphen I found solutions to each one of these problems at different places. Unique distinct list here: http://www.get-digital-help.com/2009/03/30/how-to-extract-a-un...