vba

How to allow users to quit out of long-running VBA tasks?

I have a routine that examines thousands of records looking for discrepancies. This can take upwards of 5 minutes to complete and although I provide a progress bar and elapsed time count, I'm not sure I want to encourage folk pressing ctrl-break to quit the report should it be taking longer than expected. A button in the progress bar...

Copying Data's from workbook to another workbook

Does anyone have the Macro code for copying from one excel workbook sheet data's to another excel workbook sheet but that should be date and time conditioned? ex: Date Time Fruits 4/22/2009 7:30:34 Apple 4/22/2009 7:30:37 Orange 4/22/2009 7:31:19 Mango 4/22/2009 7:31:37 Grapes 4/22/2009 7:32:37 Bana...

Copy header and range from one sheet to another

I am trying to copy a header and a set of data to a new worksheet for printing. While I can copy the data fine the column widths are lost and running autofit on it again breaks the page. The column widths were set by hand manually when the page was originally designed. Currently I have: Dim tmp As Worksheet Set tmp = Sheets.Add(after:...

MS Access 2003 - Simple value input into a text box from clicking label boxes

Ok so could anyone please help me out with the VB for auto entering information into a text box, by clicking certian label boxes on a form in access 2003. I built this thing using label boxes as "sort of links" instead of button for navigation/commands etc, and I have this power point presentation viewer on one of the forms. The client ...

VBA: Using WithEvents on UserForms

I have a Word userform with 60+ controls of varying types. I would like to evaluate the form every time a control_change event is triggered and change the enabled state of the form's submit button. However, I really don't want to write and maintain 60 on change event handlers. Could anyone help me out? Cheers ...

Version control Access 2007 database and application

I need to version control a Microsoft Access 2007 database and application. Currently everything is contained in a single mdb file. The application includes: Forms VBA code Actual database I would assume I need to separate the database from the forms/code. I would like to be able to version control the forms/code as text to support ...

PageSetup problems

In what is hopefully the last problem in the "Print An Individual Range" series of questions, I hereby humbly ask the more knowledgable readers how to copy the PageSetup object from one page to another. Since you can simply Dest.PageSetup = Source.PageSetup I have had to create function that does the same. An abridge form is below: Pub...

How to determine if there are hidden columns when copying in Excel VBA

As the title explains, I have an Excel 2003 workbook and I'm copying a number of columns of one sheet to another in VBA. Unknown to me, someone has hidden a few columns on the source sheet and it has messed up how I process the cells in the destination sheet. How can I programmically determine: IF there are hidden columns WHICH colum...

Opening ADO connection to Excel Spreadsheet in VBA

How would I go about opening an ADO connection to an Excel 2007 spreadsheet? I am doing this in order to import the data into Access 2007. Rather annoyingly, the data needs to be fltered and pre-processed before being imported, hence why I want to open an ADO connection to read it. ...

How to show "Open File" Dialog in Access 2007 VBA?

How would I go about showing an open file (or file select) dialog in access 2007 VBA? I have tried using Application.GetOpenFileName as I would in Excel, but this function doesn't exist in Access. ...

How do you remove hyperlinks from a Microsoft Word document?

I'm writing a VB Macro to do some processing of documents for my work. The lines of text are searched and the bracketed text is put in a list(box). The problem comes when I want to remove all hyperlinks in the document and then generate new ones (not necessarily in the location of the original hyperlinks) So the problem is How do I re...

Excel VBA - Use Module in Workbook B to Update Data in Workbook A

I have 10 XLS's, each of which contain a a few hundred lines of VBA that do the same thing. I want to move this common code into an 11th XLS, and have the other 10 call the code in the 11th XLS. The common code must have access to all of the data and worksheets in the calling XLS. This last requirement does not seem to be addressed by ot...

Null values reading data from Excel using ADO

I am reading data from an Excel 2007 spreadsheet using ADO. Setting up the connection is easy: Dim ado As ADODB.Connection Set ado = CreateObject("ADODB.Connection") ado.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=myFilename.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=NO;IMEX=1"";" ado.Open I can call ado.OpenS...

Is there a way to talk to OneNote through code?

I love using OneNote, however I want more control over the locations of my notes and how notes are generated. I'm very versed in VBA and ok with Python (and those are the only languages I can code with on my machine) however I haven't found a decent way to interact with OneNote through code. I'm using OneNote 2003 which doesn't look li...

ms-access vba Eval function behavior

I have a public function in access form Public Function PopupProcess() as long MsgBox Me.ActiveControl PopupProcess = 1 End Function when i call eval("forms('MyForm').popupprocess") it shows message box 2 times. Does anybody know why it does that? I Have Access 2003 with SP3. thanks. EDIT : Main idea is to call function from ...

& in procedure parameter - Purpose of "&"?

Hi All, What is the purpose of "&" in 1& in the following procedure call? sndPlaySound32(WhatSound, 1&) ...

Detect and switch Domino servers from within VBA

We are having issues with our mail server which have highlighted a weakness in a system that I set up a couple of years ago to email departments on completion of reports. The code that currently sets up the mail server is hardcoded as Set objNotesMailFile = objNotesSession.GETDATABASE("XXX-BASE-MAIL-04/CompanyName", dbString) The pro...

Excel vb code stopped working (variable not defined)

(DISCLAIMER: I'm not a programmer, I spend my time on serverfault, I'm just a lowly admin) We have an excel spreadsheet with vb code in it that was created in Office 2003. We've recently gone to Office 2007, and the spreadsheet continued to work as normal. However, after installing service pack 2 for Office 2007 the spreadsheet now fa...

Why VBA goes to error handling code when there is no error?

I have writen some code in VBA (Excel) with error handling labels. It worked fine until I recently notice the error handling code gets executed everytime, not just when an error occurs. Does anybody know why this happens? Thanks. Here's a trivial test case where both msgboxes would pop up. Sub example() On Error GoTo err_handle ...

I'd like the quickest way (in excel VBA) to identify whether one string occurs anywhere within another - an 'includes' function perhaps?

I'd like the quickest way (in excel VBA) to identify whether one string occurs anywhere within another - an 'includes' function perhaps? ...