excel-vba

Generalized inner product

I wrote a function called dot that calculates the "inner product" using arbitrary operators. It works like this L M 1 2 3 4 =dot(L:L,M:M, "*", "+", 1) This would return 1 * 2 + 3 * 4 = 14. You could replace '*' and '+' with '^' and '-' or whatever binary operators you like that work between two numbers. The cool thing a...

Wrong Object Returned from COM Callable Wrapper

I have just made an update to a dll that is called from VBA within Powerpoint. All development went fine, but when I tried to deploy on another users machine I get a problem that I have no idea how to debug. What happens is that when the .Net object is created in the VBA, the reference that is returned is to the wrong object, so the ne...

executing word mail merge from excel macro

Is it possible to start MAIL MERGE from excel macro (by clicking a button on sheet) I have excel sheet with data and want to export it to new word doc. ...

Storing Range attributes as an object?

I'm having trouble with the way I designed this little report I'm making. Is it possible to create a variable for a Range object in Excel VBA, for the purposes of applying the formatting to another Range? Here is my example: I'm creating a dictionary from the Microsoft Scripting Runtime library: Dim d as Scripting.Dictionary With t...

Read Excel rows, mark rows read

I need to use VBA to read rows out of Excel into another application, but if the process dies in the middle, I need to know which rows were read. Is the best way to put something in a column, per row, that says that row was done? Then save it after every row is read? Doesn't seem like a great way. Any help would be great. Thanks eve...

Excel Macro to Copy and Paste Format Line by Line instead of range of cells.

I am using conditional formatting in Excel 2007 to compare values row by row in cells H, K and U. Since I am trying to use the conditional fomartting row by row instead of a range of cells. My hand cramped up by row 50, and I have another few hundreds to go. Is there a macro that would check the rows and paste the format without having...

How to get the range of the visible rows after applying an advanced filter in Excel (VBA)

Here is the code that applies an advanced filter to the column A on the Sheet1 worksheet (List range) by using the range of values on the Sheet2 (criteria range) Range("A1:A100").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _ Sheets("Sheet2").Range("A1:A10"), Unique:=False After running this code, I need to do somet...

Difference between print and print preview events in excel vba

I have some code which intercepts the Before_Print event in excel to make sure that the user has filled in all the required fields before they print the sheet. However, I only want this code to fire when the user is actually printing, not when they are just calling the print preview. Is there any way to tell in the Before_Print code wh...

Automate Importing Multiple Excel Worksheets into SQL

In VB6: I need to allow a user to select an Excel file, and then upload All Worksheets to a SQL table. I'm not sure how to do this. The format of each sheet is exactly the same. And the worksheet format matches the SQL table format. I'm really banging my head against the wall over here. If anybody could offer a suggestion, or a cod...

Collaborating with a designer on the other side of the world

Hi Guys, I am trying to collaborate with a graphic designer sitting on the other side of the world. The only communication medium we have is a phone line. Every time she makes even a minute change to an element on a page, she has to take a screenshot, save it and mail it - all manually till now. As you can guess, this gets downright ir...

Excel vba: error hiding calculated field in Pivot table

I have written several Subs to show/hide fields in a PivotTable. Now I am trying to do the same with a calculated field, but I get an error when hiding it. I took my code from the recorder and the recorder's code also halts on the last line. I googled the error message, without serious result. Sub PrRemove() 'remove PR Dim pt As...

Language-independant way to refer to "Sheet"?

Hello A friend of mine works as an analyst for an insurance company, and uses Visual Basic for Applications (VBA) to write scripts. Since her company has offices in different European countries, she needs to make the scripts as language-independent as possible. One issue that came out recently is how to handle Excel documents and refe...

Copy sheet without flicker

I would like to copy a template sheet to the left of itself to be populated by a report generator. This all works fine. However when it comes to the sheet copying line (shown below) their is a flash as excel appears and then disappears - though occasionally I am left with a blue, partially filled in excel window. I already have Applic...

Connect to Excel with ADO - don't know Sheet Names

Hi, I'm connecting to Excel with ADO, but it only works if I specify the sheet names. I won't know those at runtime. Is there any method to get the sheet names? Excel automation? Thanks. ...

How to know if the VBA component of Office is installed?

My Excel addin requires the Visual Basic for Applications option of Excel to be installed in order for it to work. I would like my install (which is written with InnoSetup) to be able to detect if VBA is installed and warn the user if it is not. How can I detect if the option is already installed? ...

MS VBA and XPath 2.0

Do any VBA libraries exist which will allow me to use XPath 2.0 within VBA? MSXML6 does not work with XPath 2.0. Basically, I want to parse XML documents using XPath 2.0 as it allows me to use functions within the XPath expression to filter the XML document. As an example, the usage of the function current-date() would be useful as I w...

VBA - populating collection with arrays

hi i have the foll. code in VBA: Dim A As Collection Set A = New Collection Dim Arr2(15, 5) Arr2(1,1) = 0 .... A.Add (Arr2) can you tell me how to access the Arr2 through A? For example i want to do the following A.Item(1) (1,1) = 15 so the above would change ...

MSCOMM32.ocx Excel VBA problem

Hi, I was using an Excel macro which uses mscomm32.ocx for communicating with the serial port. It was working fine until some one or two month back. Now when we try to run it again it is not working. When I try to load it, it says the "Subject is not trusted for the specified Action". Can any one help me out!? Thanks... ...

Calling SSL Enabled services from MSExcel ?

I have web service deployed in Web Sphere and this service is SSL enabled. I have to call this service from ms excel. I am using MSSOAPLib.SoapClient to call my web service. When I run this macro i am getting security related error. That is the public key should be stored in the client key store. Please let me know how to do this. Also ...

How do you format text/strings in VBA?

In the code below, I take some input parameters, either text or a cell, and combine them to form one string using the formatting I need. I need to make Task_Name bold, as well as text like "Lead :". I know you cannot make text in a variable bold, but how do I go about this? This cell I'm storing the value in is eventually used in a Wo...