vba

Predict text wrapping in cell, Excel 2000, using vba

The problem: I use VBA to populate MS Excel 2000 cells with text. The column has a fixed width (should not be changed due to layout) and the wordwrap property is set to true so the text wraps over multiple lines if wider than the column. Unfortunately, the row-height do not always get updated accordingly. I need a way to predict if the t...

Geocoding using Google Earth

Dear all, I would like to get a pair of coordinates (longitude, latitude) from a postal address. I am coding VBA in an Excel workbook. I can assume that Google Earth is installed and registered as COM server. Thus I have been looking for a way to use the Google Earth COM API to achieve this, however I have not managed to find anything....

What is "Dim fso, MyFile, FileName, TextLine" in VBA?

I received this code from one of those nice people here who are willing to spend their time and energy to share their knowledge with noobs: Sub ReadLinesFromAFileOneAfterAnother () Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim fso, MyFile, FileName, TextLine Set fso = CreateObject("Scripting.FileSystemObject") FileName = ...

Range.Formula= in VBA throws a strange error

This except of VBA code summ = "СУММ(AQ" + Format(first) + ":AX" + Format(last - 1) + ")" cell = "AQ" + Format(last) + ":AX" + Format(last) r.range(cell).Formula = "=" + summ should insert a formula, e.g. =СУММ(DW6:EI18) into DW19. (СУММ is a Russian localized name for SUM) What happens is that correct formula above appears at its p...

Which command in VBA can count the number of characters in a string variable?

Let's say I have this variable: word = "habit" which command in VBA will allow me to count how many characters are there in this variable (in my case it's 5). Important: the variable "word" contains only one word, no spaces, but may have contain numbers and hyphens. ...

Excel VBA Colon

I have the following declaration in Excel VBA Public Const cdbArea = 1: Public Const cdbDist = 2: Public Const cdbChange1 = 4: Public Const cdbChange2 = 5: Public Const cdbTR = 5: Public Const crbArea = 1: Public Const crbDist = 2: Public Const crbTerr = 3: Public Const crbChange1 = 4: Public Const crbTR = 5: Public Const cdbWeek1 = 4 ...

MDX retrieve recordset

I am trying to match existing reporting functionality while building up a new cube for a Proof of Concept. Can I retrieve data from my cube using an MDX query and put it into a recordset so I can then populate an Excel Sheet with the data? ...

excel macro to select multiple row

I have excel macro to select a row to cut and paste to next sheet. Now I want to select multiple row at one time to cut and paste to next sheet, then go back to previous sheet to delete the blank rows that were cut. The code I have for the single row cut and paste is follows: Sub CutPasteRows() Dim iLastRow As Integer 'select the ...

Connecting to Oracle 10g with ODBC from Excel VBA

Hi, The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes Excel. Any ideas?? Thanks Sub GetData() Dim conn As New ADODB.connection Dim connString connString = "DSN=name;Uid=user;P...

How to concatenate strings in Excel

This question comes from a comment to Range.Formula= in VBA throws a strange error. I wrote that program by trial-and-error method so I naturally tried + to concatenate strings. But is & rather than + more correct method for concatenating strings? ...

Outlook 2007 CommandBarControl.Execute won't work

I recently switched to Outlook 2007 and noticed that my VBA-macros won't work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, but now the objCB.Execute just does nothing. I tried different control IDs and it only works for some, but I could not figure out why or why...

How to get file path of the file with the running-vba code.

I want to get the folder path from the file who is running the vba-code. For example: the vba-code is in the file C:\myfolded\file.accdb and I want the vba-code to return C:\myfolded\ Is that possible? ...

Handling no results for docmd.applyfilter

Hi, I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wilcard search of whatever the user enters in the TextBox, and displays the records in other controls (Text and Combo Boxes). To achieve this, I am using the DoCmd.ApplyFilter method and I wanted to know if there ...

Is there a way to overload the constructor / initialize procedure for a class in VBA?

In C#, I know that I can overload the constructor for a class by specifying it in the body of the class: public class MyClass() { public MyClass(String s) { ... } } This overrides the default constructor (which has no parameters) and forces the class to be initialized with parameter s. I know that in VBA I can initialize my class...

How do I access a class module in Excel VBA from C#?

I have an Excel add-in with a class module. I want to instantiate the class module in C# and call a method on it. How do I do that? ...

Copy data from lookup column with multiple values to new record Access 2007

I am copying a record from one table to another in Access 2007. I iterate through each field in the current record and copy that value to the new table. It works fine until I get to my lookup column field that allows multiple values. The name of the lookup column is "Favorite Sports" and the user can select multiple values from a dropdow...

Excel Help Needed: insert row with total under each group

i need to insert row with total and a page break under each group e.g. http://i1012.photobucket.com/albums/af250/nsy2204/question.jpg (i cant post images so i posted the link..) i tried the following to insert row... however it inserted rows rather than one rows.... Sub macro() Dim sh1 As Worksheet Dim i As Long, lastrow...

Is there any way to add a specific category and flag an email in VBA?

I normally go through my email and flag anything for follow up and categorize for: Phone Call Email Talk To Setup meeting Is there any way in a Outlook VBA macro, I can (in a single macro), both flag an item for follow and set one of the above categories on it? ...

Why doesn't this Outlook 2007 VBA work (I'm trying to remove a flag programatically)?

I have some code that adds a flag to an email but when I try this code below to remove it, it doesn't seem to have any effect in Outlook 2007. Public Sub Clear() Dim objOutlook As Outlook.Application Dim objInspector As Outlook.Inspector Dim strDateTime As String ' Instantiate an Outlook Application...

How-to: Run existing Word VBA Macros from C# Ribbon Addin

Background: I have an extensive set of specialized VBA macros used in Word for document formatting purposes. In Word 2003, these macros were activated from a customized toolbar. I have recently transitioned to Word 2007 and would like to be able to run these existing VBA macros from a new Word Ribbon created with VS 2010. I have created ...