vba

Calling AppActivate on a word 2007 window in Windows 7 gives it focus but doesn't bring it to top of stack

I'm trying to manipulate Word from an HTA file application. Currently, when I open word, it opens underneath my application. I'd like to open it on top. I've tried using the following JScript to give Word the focus: wshShell = new ActiveXObject("WScript.Shell"); wshShell.AppActivate(doc.windows.Item(1).caption); This works, and word g...

question about frequency of updating access

i have a table in an access database this access database is used on a regular basis, basically from 9-5 someone else has a copy of this exact table. sometimes records are added, sometimes deleted, and sometimes data within the records is updated. i need to update the access database table with the offsite table every hour or so. what...

Is there a universal way to get a nice textual representation of a variable in VBA?

In VBA, is there a nice way to get a textual representation of a variable / object? Like Java's various String.valueOf(...) methods. ...

If/Then in SQL Embedded in VBA

I've got a string like this in my Excel VBA: strSQL = "SELECT * FROM Total WHERE (SimulationID = (" & TextBox1.Text & ") And Test1 = (" & Example & "))" However, sometimes Test will be 'is null', which makes the query And Example = is NULL How can I change it to add an if/then statement or something to make it say And Example is ...

Inserting new argument to table through search form of another table

In my database I have a form for searching products (fields : id, name, manufacturer_id[set to display manufacturer's name], category_id, price). I would like to have the ability of adding manufacturers through this form. So I've created vba script but it does not work. Still when I enter new name it gives me prompt to "Select element fr...

How to Trigger a Error from a VBA function

hi, I need to trigger(return) an error event from a VBA function, then the calling function of this function can trigger On Error Go to call. E.g function Test() On Error Go to myError: TestErr() Exit Function myerror: Test = "Error Triggered" End Function Function TestErr() ?? 'How to Trigger error here End Functio...

How to ensure sequence of functions calling in a Excel sheet

Hi, Is there anyway to control the sequence of function calls in a excel sheet when it is re-opened ? Excel automatically re-evaluate the functions when it restarts, where I need to ensure one of my function set is called before another set of function calls. Thank You ...

Upload files from website

All I want to do is allow the user to browse through their folders to look for a file, select it and then press submit which saves the file to my server as well as the path to the saved file. How would someone do this? (Some sort of tutorial website would help a lot) ...

How to tell if 2 arrays share the same element.

So this is a simpler form of my problem. Lets say I have 2 arrays. A= {1,2} and B={2,4,6}. If A and B share an element then delete that element from B. I know you can loop through and compare each element in A to each element in B, but there's got to be a better way! ...

MS Word DDE: What does destroy my encoding?

I'm facing a problem with a MS Word DDE Automation controlled by our CRM system. The setup Base for the document created is a Word .dot template which fires a macro on Document.New. Inside this macro I create a .Net component registered for COM. Set myCOMObject = CreateObject("MyCOMObject") The component pulls some data from a datab...

excel quotes in formula question

i have a column with this data: IT_AMPH IT_BARB IT_BENZ IT_BUP SOMA i want the column next to it to be literarely =like "*,IT_AMPH,*" =like "*,IT_BARB,*" =like "*,IT_BENZ,*" etc please note that i want the equal signed to be displayed, exactly as shown above what would be the formula for this? ...

What is the difference between Range.Columns and Range.EntireColumn

Dim r as Range Set r = Range("C2:D3") Dim r1 as Range, r2 as Range Set r1 = r.EntireColumn Set r2 = r.Columns Won't both ranges represent the range "C:D"? What is the difference between the two? ...

Outlook 2007 : VBA Macro: GUI update (HourGlass for Mouse Pointer) not happening?

I have a simple VBA program to download attachments from a Mail Item; I'm launching a Macro (that is a 'sub' in a Module), which does a 'Form.Show' to launch a User Form. There is a button on the User Form to kick of the actual download - the download sub is located back in the Module code, not the form code. Here's the code I'm using f...

Where can I find the procedure called from this Excel VBA Application.Run statement?

I'm working with an Excel VBA "Sub" that contains a statement like: Application.Run ("Menu_SomeProcedure") which is calling some code or functionality which I need to inspect but I'm unable to find the implementation of "Menu_SomeProcedure" anywhere in the VBA module code. Where should I look to find it? I am using Microsoft Office ...

Speed up an Excel Macro?

Right now I have a macro PopulateYearlyValues But it seems to me it's taking way too long Sub PopulateYearlyValues(ByVal Month As Range) Dim c As Double Dim s As Double c = Application.WorksheetFunction.Match(UCase(Month.Value), ActiveSheet.Range("AA5:AX5"), 0) s = (ActiveSheet.Range("AA5").Column - 1) With ActiveShe...

It's easy to set a breakpoint when debugging VBA, but how about a "startpoint" or a "skippoint"?

I'm debugging a subroutine in my VBA code. I want to ignore the first half and just run the second half. So, is there a way to set a 'startpoint'? Also, is there an easy way to ignore a specific line of code other than commenting? If not, I'll just continue commenting out all the code I don't want run. The problem with this, of cour...

Calling a Add-in function from Excel's VBA

I am using an Excel Add-in for an Erlangs: http://abstractmicro.com/erlang/helppages/ref-erlbblockage.htm I try to call the Erlang-B function within the Add-in from within VBA thus: Function Erl(Erlangs As Double, Capacity As Double) Erl = Application.WorksheetFunction.ErlbBlockage(Capacity, Erlangs) End Function ...but it doesn't w...

unconventional sorting in excel

i have a list like this: G05 G03 F02 F06 G10 A03 A11 E10 E05 C11 C03 D03 A12 C12 F05 H03 C08 G02 D10 B12 C10 D11 C02 E11 E02 E03 H11 A08 D05 F04 A04 H07 D04 B07 F12 E04 B03 H05 C06 F08 C09 E08 G12 C04 B05 H09 A07 E09 C07 G07 G09 A06 D09 E07 E12 G04 A10 H02 G08 B06 B09 D06 F07 G06 A09 H06 D07 H04 H10 F10 B02 B10 F03 F11 D08 B11 B08 D12 H...

Call Single StrConn from Multiple Pages

I have a ocnnection to SQL Server set up in my vba code. The format is: strConn = "ODBC;Driver=SQL;Server=SQL1;Database=DB1;Uid=1;Pwd=1" I have this in 4 sheets, but there will be times when I will want to change it to call from SQL2 or SQL3, and instead of changing the code on each sheet 4 times, I want to change it only once. Is t...

Getting The Maximum Of An Excel Chart's Y Axis (When There Are Two)

I would like to know how to programmatically find and the Y axis maximum of an excel chart when there is more than one available. My end goal is to find the max y-axis values, compare them, and set them both to the greater of the two. ...