vba

Brackets around Stored Procedure in ADODB Command Text

Help me understand why this is happening! I use the ADODB.Command object. The Command Text is set to the Stored Procedure Name. Sometimes, if I DON'T add brackets around the stored procedure name, I get a Syntax Error or Access Violation error. Sometimes, if I DO add brackets around the stored procedure name, I get a Syntax Error or ...

How to import multiple vCard VCF contact files into Outlook 2007 using VBA

How to import multiple vCard VCF contact files into Outlook 2007 using VBA ...

Find size of dictionary object in VBA

What is the simplest way in VBA to determine the size (i.e., number of keys) in a dictionary object? ...

using Excel VBA, given the daily price of 50 stocks, choose 10 stocks such that they have the minumum correlation

The high-level goal is to choose 10 stocks that have the lowest correlation among one another, out of a pool of 50, so that I can have a well-diversified portfolio. I have managed to write some VBA macro to download the past 3 years of daily price data from Yahoo finance, and then compute the 50x50 correlation matrix (using the Correl f...

Why is Excel's 'Evaluate' method a general expression evaluator?

A few questions have come up recently involving the Application.Evaluate method callable from Excel VBA. The old XLM macro language also exposes an EVALUATE() function. Both can be quite useful. Does anyone know why the evaluator that is exposed can handle general expressions, though? My own hunch is that Excel needed to give people a w...

How do I turn off autocorrect in VBA in Excel 2007?

My VBA in Excel 2007 is going crazy and it's automatically moving my cursor all over the place. Is this supposed to be happening? Is there some way to turn this off? ...

how can i program this ui box

in what way can this be programmed. a UI box that displays random number between min and max value for 2 seconds then shows blank for 2 seconds then shows another random numer for 2 seconds then shows blank for 10 seonds and then repeats the cycle infitely until form closed. Font of the text to be configurable. any help at all will be ...

run-time error '429' activex component can't create object

I've created a simple application .Net Class that converts an excel spreadsheet into a a pdf file. I then get a Excel 2007 application to call this dll which works fine on my development machine. However when i deploy it on to a Vista machine that has both the .net framework and excel 2007, i get this error - run-time error '429' acti...

Excel tab sheet names vs. Visual Basic sheet names

It seems that Visual Basic can not reference sheets according to user-modified sheet names. The worksheet tabs can have their names changed, but it seems that Visual Basic still thinks of the worksheet names as Sheet1, etc., despite the workbook tab having been changed to something useful. I have this: TABname = rng.Worksheet.Name '...

Excel VBA ComboBox2 doesn't get the right content

Hi, I'm having a problem with the content of a combobox. On my userform, there are 3 comboboxes. Depending on the chosen item from combobox1, combobox2 should display either set 1 or set 2. The same will be happening with the content of combobox 3, which depends upon the combination of chosen items from combobox 1 and 2. However, I'...

Pulling data from a text file to generate a report

Have a program in MS-Access, using VBA. I need to come up with an If statement to pull data from a text file. The data is a list of procedures and prices. I have to pull the prices from the text file to show in a report how much each procedure costs. ID PID M1 M2 M3 Total 1 11120390(procedur...

VBA Excel macro: use Range to act on a different worksheet

I am very much a beginner when it comes to VBA programming. I have a Macro that hides or shows columns based on the value in one cell: Sub HideColumnsMacro() Range("b8:o8").EntireColumn.Hidden = False v1 = Range("b2").Value + 1 If v1 < 12 Then With Range("b8") Range(.Offset(0,v1), .Offset(0, 12)).EntireColumn.Hidden = True En...

MS Access Print Report using VBA

I have a very VBA intensive report. When I preview it everything is great but when I print it after previewing things go wacky. I have spent many hours narrowing down the possibilities and I have conclude with a certain level of confidence that it is a bug in MS Access. Up to this point my method for printing reports was to open the rep...

VBA: How go I get the total width from all controls in an MS-Access form?

Hi, This is probably very basic stuff, but please bear in mind I am completely new to these things. I am working on a procedure for my Access datasheet forms that will: Adjust the width of each column to fit content Sum the total width of all columns and subtract it from the size of the window's width Adjust the width of one of the c...

Infopath Attachment Field; Submit in SQL Server

Hi all, Is there a way to get the attachment from the form to an SQL Server column using VBA? There are some examples about encodind and decoding attachments, though is this the case? Does SQL server support attachments somehow? Thanks in advance, Sun ...

Converting big-endian into little-endian and vice-versa in VBA

My machine is little-endian (Intel byte order). I need to read a binary file containing 16-bit signed integer data in Motorola/IEEE byte order ("big-endian"), then do some calculations, and finally write the resulting integer data in a big-endian binary file. How do I do the above in VBA, i.e. convert big-endian into little-endian and ...

Why does VBA Find loop fail when called from Evaluate?

I am having some problems running a find loop inside of a subroutine when the routine is called using the Application.Evaluate or ActiveSheet.Evaluate method. For example, in the code below, I define a subroutine FindSub() which searches the sheet for a string "xxx". The routine CallSub() calls the FindSub() routine using both a standard...

Integer Overflow in VBA project

Hi, everyone. Here is a small VBA (Excel) function that i wrote, full of MsgBoxes for debugging. I am passing in the numbers 10 and 1 as arguments, and getting an overflow error when the program reaches the top of the For loop, before it begins the first iteration. Any thoughts are appreciated. Declare Sub Sleep Lib "kernel32" (ByVal...

getting a combo box that has a row source equal to a query - and the query takes data from a form - to update

I have a combo box with a row source based on an SQL query about like SELECT DISTINCT Database_New.ASEC FROM Database_New WHERE Database_New.Date>= DateSerial([cboYear], 1, 1) And Database_New.Date<= DateSerial([cboYear], 12, 31); the trouble is that if I change the value of cboYear, the values in the drop down cboASEC do n...

Check whether Excel file is Password protected

I am trying to open an Excel (xlsm) file via VBA. It may or may not be protected with a (known) password. I am using this code: On Error Resume Next Workbooks.Open filename, Password:=user_entered_pw opened = (Err.Number=0) On Error Goto 0 Now, this works fine if the workbook has a password. But if it is unprotected, it can NOT be ope...