vba

Read undo history in VBA

I have a fairly simple bit of VBA in Word 2003 that changes the document's font to an 'eco font' (long story), and brings up the Print dialog. When a user hits Cancel or OK, the code does an 'undo' to revert the change. The problem is, sometimes when I press "OK" to print the document, two actions need to be undone ('font change', and ...

How can I use search results of Google in Excel VBA?

I copy search results of Google and want to stick it on Excel now. I was able to write it to the place to search in IE, but do not understand more than it. Sub get() With CreateObject("InternetExplorer.application") .Visible = True .navigate ("http://www.google.com/") While .Busy Or .readyState <> 4 DoEvents Wend .document.all.q.Value ...

Normalising data - bulk inserts using loop

Hi guys Does anyone have any tips that could help speed up a process of breaking down a table and inserting a large number of records into a new table. I'm currently using Access and VBA to convert a table that contains records with a large string (700 + characters) into a new table where each character has its own record (row). I'm do...

Using VBA to Update a form recordset in Access 2007

I'm doing some development in access and I'm running into an issue where I need to make sure that a form is updated in a buttons OnClick handler. I was thinking that it might work something like this: if me.dirty then me.update 'This is a nonexistent form method' end if <rest of handler> If such a thing exists, will I have to...

Outlook VBA: UserForm not responding (can't close, button click event doesn't fire)

I've created a simple UserForm in my Outlook VBA macro - I can make the form visible using this code: VBA.UserForms.Add (PasswordForm.Name) PasswordForm.Show (Modal) ...and the *UserForm_Initialize()* event does in fact fire. But clicking on the "Submit" button on the form does nothing - the SubmitButton_Click() event (which was auto...

How do I access some sort of OnLoad event in Word 2007 VBA?

Hello, I am trying to have some code fire when the document is first loaded, but there are two problems. First, I don't know which method to call to get something to fire when the document is first opened. Second, if they have macros disabled, how can I be sure that it gets called when they are enabled? Thanks! ...

How can I sum and replace column data and do averaging all in a MS Access query?

I am pulling data from one table, called analyzedCopy, and using it to over-rite all information in another table called analyzed. The columns I'm sorting/filtering/manipulating, are readings_miu_id, ReadDate, ReadTime, RSSI. I am currently moving data from analyzedCopy to analyzed using the following sql that to get only the last time(h...

How do you redimension an array in VBA?

I'm attempting to rediminsion an array in MS Access VBA. What is the most efficient way to do this? ...

VBA and WinHttp: how to submit to a page that may redirect to a login page

I am using a macro in outlook VBA to submit a file via POST to a URL: Set http = New WinHttp.WinHttpRequest http.Open "POST", UrlToPostTo, False 'True ' http.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" http.setRequestHeader "Content-Type", "multipart/for...

Is there a way to access VBA help files from the command line

I'm going to have to write a number of vba modules for a project I'm working on, and would prefer to use SciTe to the built in editer in Office. SciTe allows you to redirect the effect of hitting F1 to a arbitary command with the selected text as an argument. Is there anyway of using this functionality to search the relevant .chm files?...

What Excel VBA actions are possible on hidden worksheets or workbooks?

Hidden worksheets/workbooks have some limitations to what can be done in VBA code, like most Select and Selection statements, and anything coming from ActiveSheet, but I can't seem to find any list of what the limitations are. Google, the built-in documentation in the help system, and MSDN's website have all failed me. Can anyone point...

When I try to use a VBA function that I've defined in an Excel spreadsheet, I get "That is not a valid function"

I defined a function in VBA as follows Public Fuction Distance(X, Y) as Double Then in a cell i try to use the fuction. I type "@Dis" and get the drop down menu, select the function and then enter the parameters ending up with @Distance(A1, A2) in the cell. When I press Enter I get the Error "That function is not valid". I enabled ...

How to use VBA to automate several Office applications?

Although I've done VBA projects within a single application for both MS Access 2007 and Excel 2007, I haven't automated multiple applications at the same time. The generalized project is to open access, run some update queries that appends data to various tables. Then Excel needs to get the data. Some formating changes are needed in E...

ODBC connect with propritary driver/Excel Trust settings

I have a spreadsheet in Excel that connects to an internal DB using the odbc driver for the software (Action Request System). That works fine. Now I'm trying to move the Excel file to a SharePoint site so that our team can review the data and make notes in the same spreadsheet. So, first I tried just moving the Excel file to the server,...

Can't add to a Double type

I have a double value I would like to increment, using the following snippet: Total = CDbl(Total + CDbl(Workbooks(1).Worksheets(1).Cells(1,1).Value)) The code continuously returns a type mismatch error, even though the cell it points to has a decimal value in it. What am I doing wrong? ...

How do I get the cell value from a formula in Excel using VBA?

I have a formula in a range of cells in a worksheet which evaluate to numerical values. How do I get the numerical values in VBA from a range passed into a function? Let's say the first 10 rows of column A in a worksheet contain rand() and I am passing that as an argument to my function... public Function X(data as Range) as double ...

Office 2002 - VBA Application Migration to Office 2007

Looking for Migration from Office 2002 - VBA Word Doc Application to Office 2007. Issues :- Though Office 2007 Supports VBA Application - VB Macro Code, Menu Bars are not appearing. Indeed, VBA Macro Menus display under "Add-ins". On a study, I realized Office 2007 Supports XML - Ribbon. Is there any ideal approach to migrate VBA Macro...

Convert Word template from MS Word 2003 to MS Word 2007

I have a problem moving a Word template from Word 2003 to Word 2007 The code which I need to convert is Sub Standardbrev() Documents.Add Template:= _ "p:\setup\stdbrev.DOT", NewTemplate:= _ False mask "<Navn>", False mask "<Adresse>", False mask "<Postby>", False mask "<att>", True mask "<Jura ...

How can I run SQL statements on a named range within an excel sheet?

This is a very simple question which I am pulling my hair out with. No amount of web searching seems to help! All I am trying to do is take a standard range on an excel sheet (i.e. a named range, or even A1:F100), and run some sql queries on it, and return a recordset that I can either step through in VBA code, or even just paste into s...

Does VBA have Dictionary structure?

Hi. Does VBA have dictionary structure? Like key<>value array? ...