vba

VBA or .NET for working with Office?

Hi All I want to develop and automate Office software like 'Microsoft Excel 2007' And 'Microsoft Word 2007'. But I do not know how to use VBA or use C#/.Net Framework to do so. What are the benefits of using VBA vs .Net framework? Which one should I focus on learning? ...

Access 2007 VBA : Building a listbox with selection choices from another list box

So there are 8 categories that may be associated to each order, but not necessarily all of them. So i was going to build a list box that allowed the user to double click each of the category they wish to associate when they have an "Order Detail" form opened up (unbound form that has hidden text boxes with all needed ID numbers). I want...

VBA speech recognition /audio input / voice command

Speech recognition may be too grand a term for this problem. I want my VBA program to wait for the user to say something like "next" or "continue" before it carries on processing. This is the equivalent of the traditional "Press any key to continue" loop. This should be fairly simple. All the examples I have found do complicated thing...

how much do these speed up your macro? Application.ScreenUpdating = False Application.DisplayAlerts = False

what is the point of doing these: Application.ScreenUpdating = False Application.DisplayAlerts = False does it really save that much time? ...

Bang Notation and Dot Notation in VBA and MS-Access

While perusing an application that I'm documenting, I've run across some examples of bang notation in accessing object properties/methods, etc. and in other places they use dot notation for what seems like the same purpose. Is there a difference or preference to using one or the other? Some simple googling only reveals limited informati...

Concatenation yields error with underscore

I am trying to create a macro that brings in the name of the sheet and combine it with text. For example, for sheet one, I want it to say "ThisIs_Sheet1_Test" in I5 of Sheet1. There are several sheets but it should work for all of them. What is wrong with my code? I think the underscore might be ruining it all. Here's what I have: Dim ...

Vba to Access record Insert Issue

I want to insert Values to access table by using VBA control is there is any simple way to do this. i try this code but it does not work properly if i run this code it give the error 'variable not set' can anyone help me. thanks in advance Private Sub CommandButton1_Click() Dim cn As ADODB.Connection Dim strSql As String Dim lng...

Sleeping in VBA (Integer Overflow!!)

In VBA you can Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) to provide yourself with a sleep routine. However, the Long that must be passed to the routine appears to overflow for values in excess of 32000 milliseconds. Is there a way to sleep for longer periods of time without the complexity of stringing together s...

Excel VBA File not Found

During development of some Excel vba code about every other iteration where I go in and add some code then save the file, the next time I open the thing (it is automatically set to run the code on open) I get a spurious "File not Found" error. To fix it I copy all the code- modules and classes plus the startup code, to a fresh blank exc...

ACCESS VBA - DAO in VB - problem with creating relations

So take the following example: Sub CreateRelation() Dim db As Database Dim rel As Relation Dim fld As Field Set db = CurrentDb Set rel = db.CreateRelation("OrderID", "Orders", "Products") 'refrential integrity rel.Attributes = dbRelationUpdateCascade 'specify the key in the referenced table Set fld = rel.CreateField("OrderID") fld....

Access 2007 - cycling through values in a list box VBA?

So i have a list box that populates with different sets of data based on user selections. How can I cycle through any given values that may be in the list box? Is this a For Each statement, or what? Please help thanks justin ...

How do I Increase cell value in Excel using VBA? Error: Type mismatch

I'm writing a macro, but because I'm working for first time in vb, I faced problems. My code: Cells (1, 1).Select Dim tempvar As Integer tempvar = Val(Selection.Value) // error Selection.Value = tempvar + 1 What my code should be: Cells(1,1).Value+=1 I get error "type mismatch". How do I accomplish that? EDIT: Row 1, Cell 1 is me...

How to fill many texbox by using loop function in VBA

Hi ! I made a user interface in VBA with many textbox. I read an excel sheet and I put all the value of this one in all the textbox of my user inteface. So the user can modify the values and then save it in the excel sheet. Because we can't name the textbox like array (textBox(1), textbox(2)....) this is hard to fill the textbox by usi...

How can I specify processor affinity?

I have an application that's having some trouble handling multi-processor systems. It's not an app that I have a particular affection for modifying and would like to avoid it if possible. However, I'm not above modifying the code if I have to. The application is written in VBA (and hence my inclination to avoid touching it). We've no...

VBA - Access 03 - Iterating through a list box, with an if statement to evaluate

So I have a one list box with values like DeptA, DeptB, DeptC & DeptD. I have a method that causes these to automatically populate in this list box if they are applicable. So in other words, if they populate in this list box, I want the resulting logic to say they are "Yes" in a boolean field in the table. So to accomplish this I am try...

Export and Import MS Access table defenitions as text files

How can I export/import MS Access table definitions as text files (in a human readable format like I can with Forms or Reports)? I know how I can export the whole table out into CSV file; however: I don't need the data to go (actually really rather that it didn't) When I import a CSV file (especially without data) there's no guarantee...

Pull in Earlier Value Using Concatenation

I have code that works in some situations but not in others. I have this code: Public Sub ListBox2_LostFocus() ListBox2.Height = 15 With ListBox2 ThisIs_Sheet1_Test = "'" For i = 0 To .ListCount - 1 If .Selected(i) Then ThisIS_Sheet1_Test = ThisIs_Sheet1_Test & .List(i) & "','" End If Next i End W...

Is there a getproperty or equivalent function in VBA?

I'd like to know if something like this pseudo code: myVar = "functionName" call someObject.(myVar evaluation) which would then be equivalent to: call someObject.functionName is possible in VB. I know this is done in some other languages using a GetProperty method. Thanks in advance. ...

Beginner Access VBA SQL INSERT Question

Syntax question: I am using the code below to call a query in Access VBA strSQL = "INSERT INTO tblLoanDetails ([ServerName]) VALUES ('Test') WHERE [ID]=3" Call CurrentDb.Execute(strSQL) And i am getting a runtime error of "3067: Query must contain atleast one table or query." the insert statement string looks like this (Threw the var...

MSForms.ListBox Type Mismatch in Access

I have an Access database where I use a Tab control (without tabs) to simulate a wizard. One of the tab pages has an MSForms.ListBox control called lstPorts, and a button named cmdAdd which adds the contents of a textbox to the List Box. I then try to keep the contents of the ListBox sorted. However, the call to the Sort method causes a ...