vba

Add a Keyboard shortcut to AutoKeys macro from VBA in Access 2003.

I have an Access 2003 application and it has AutoKeys macro. I would like to add an another Keyboard shortcut to this application from my VBA module. How can I do that? ...

MS Access: Copy/Paste selected record programmatically?

Sorry for the lengthy introduction but I think it best to explain the context of my question. I have an Access 2003 database in which users need to create new records based upon pre-existing records already in the table. Some of the users of the database are more familiar with computers in general and create a new record by ... 1. Selec...

Manage spreadsheet versioning

We have a lot of VBA code in spreadsheets and a lot of time people save them to local drives. When we want to upgrade the spreadsheets we push a new version out to a shared drive but dont have any way of enforcing that people dont use the old versions of the spreadsheets. Is there some best practice here to deploy vba spreadsheets so...

How do you scale a pictureLink object in Excel 2010

In Excel 2007 it is possible to scale a pictureLink object (created with the Camera Tool) using the following VBA code. With ActiveWorkbook.Sheets(sht).Pictures(name) .ShapeRange.ScaleWidth scaleValue, msoTrue .ShapeRange.ScaleHeight scaleValue, msoTrue .top = top .left = left End With This code places the picture corr...

How to list all files of a given folder (recursively through sub-folder)?

I'm writing a microsoft word macro and having difficulty with vb.net. Please help. ...

VBA Tab Key putting actual Tab Value in Text Box instead of navigating to next control

I have a VBA form (in Excel if that matters) that contains text boxes. On three occasions, I have found myself pressing the tab key to navigate to the next control, but instead an actual TAB is being put in the text box. The form normally acts as it should, but it does concern me that this gremlin is showing up sporadically. It has sh...

How does Access 2007's moveNext/moveFirst/, etc., feature work?

I'm not an Access expert, but am an SQL expert. I inherited an Access front-end referencing a SQL 2005 database that worked OK for about 5000 records, but is failing miserably for 800k records... Behind the scenes in the SQL profiler & activity manager I see some kind of Access query like: SELECT "MS1"."id" FROM "dbo"."customer" "MS1"...

XML Deserialization in VB/VBA

I have a set of VBA classes in an MS Access database. I have an xml string with data I want to create new classes with. Other than setting each property individually, is there an easy way to deserialize the XML into my object? I've seen the code using the TypeLib library Public Sub ISerializable_Deserialize(xml As IXMLDOMNode) Dim...

"Out of Memory" error in Lotus Notes automation from VBA

This VBA function sporadically fails with a Notes automation error "Run-Time Error '7' Out of Memory". Naturally, when I try to manually reproduce it, everything runs fine. Function ToGMT(ByVal X As Date) As Date Static NtSession As NotesSession If NtSession Is Nothing Then Set NtSession = New NotesSession NtSes...

How do I declare a global variable in VBA?

I wrote the following code: Function find_results_idle() Public iRaw As Integer Public iColumn As Integer iRaw = 1 iColumn = 1 And I get the error message: "invalid attribute in Sub or Function" Do you know what I did wrong? I tried to use Global instead of Public, but got the same problem. I tried to declare ...

Invoke a COM addin option from VBA

Can I invoke an option on a COM Add-in from a VBA macro in Word or Excel 2007? The COM Add-in was written using VSTO – it adds a custom ribbon tab with a number of options that I want to execute from a VBA macro. I can reference the add-in using Application.COMAddIns("MyAddinName") but I can’t find an option to invoke an option. I’ve a...

Excel 2010 64 bit can't create .net object

I have a simple class library that I use in Excel. Here is a simplification of my class... using System; using System.Runtime.InteropServices; namespace SimpleLibrary { [ComVisible(true)] public interface ISixGenerator { int Six(); } public class SixGenerator : ISixGenerator { public int Six() { return 6; } } } I...

Copying Data to a Master sheet from other sheets without duplicates

I have four workbooks, three of which are for data entries, and the latter which hosts all data entered in the other workbooks; as a matter of fact, it serves as a master workbook. I need code to copy data entered in each workbook in sheet 1 to be copied to the next available row on sheet 1 of the master workbook, but if the data to be ...

Creating an Equation Editor 3.0 equation in a Word 2003 document using a marco (or through the API)

I think the title is fully descriptive now. Anyway, I need to generate a word document from my delphi application. It needs to choose from one of four different equations (with some specific parameters for each document). So far I have manage to create the whole document programmatically except the equation. Is it possible to create eq...

Testing for NaN in VBA/VB6

Using VBA I am loading an 8-byte floating point number from an array of bytes into a Double. Some numbers will be IEEE 754 NaN (i.e. if you try to print it with Debug.Print you will see 1.#QNAN). My question is, how can I test whether the data contained in the Double is an NaN as opposed to a regular number? Thanks. ...

VBA Sleep Doesn't Work...

I know I'm doing something wrong here. I'm trying to use the sleep function to delay my code, but I get "Sub or Function not defined" error. Any tips? ...

Upload file via HTTP from VBA (WinHTTP)

Hi all, I'm trying to (HTTP) upload a binary file programmatically from within VBA. I intend to put an ASPX page on the server to accept the file and certain additional parameters. I know there are lots of nice ways to do that (e.g. use web service instead of aspx), but my constraint is that it must run in VBA (in an excel file), and t...

Why can't I get properties from members of this collection?

I've added some form controls to a collection and can retrieve their properties when I refer to the members by index. However, when I try to use any properties by referencing members of the collection I see a 'Could not set the ControlSource property. Member not found.' error in the Locals window. Here is a simplified version of the c...

Problem evaluating NULL in an IIF statement (Access)

Item in the recordset rstImportData("Flat Size") is = Null With that, given the following statement: IIF(IsNull(rstImportData("Flat Size")), Null, cstr(rstImportData("Flat Size"))) Result: Throws error 94: Invalid use of Null If I change the statement by removing the type conversion upon a false comparison: IIF(IsNull(rstImportData(...

Problem using OLEDBCOMMANDBUILDER.

So, here it goes: I need to copy data from table in access database, in another table from another access database. Column names from tables are the same, except the fact that the FROM table has 5 columns, the TO table has 6. here is my code: dsFrom.Clear() dsTO.Clear() daFrom = Nothing daTO = Nothing conn_string1 = "Prov...