vba

Is there a tactical (read 'hack') solution to avoid having the VBA code and Excel sheet as one binary file?

As I understand it when I create an Excel sheet with VBA code the VBA code is saved as binary with the sheet. I therefore can't put the code into source control in a useful way, have multiple devs working on the problems, diffing is difficult, etc. Is there a way round this without switching to VSTO, COM addins etc? E.g. for the sheet...

Parsing a web form in to a data table

Hi to all, has anyone an idea of how to write a dynamic data parser in VBA to capture data from a text file and input it in to a database table (ms access)? The form has about 55 fields, so I'd rather write a code that is capable of picking up the field name from the text than copying a load of text. Is there a smart way to do this and a...

Passing and Receiving an Array from Function

I have made a bunch of 2D arrays in Excel, and I have written a function to put the same data in a copy of each. I'm not quite sure I'm getting the fiddly parts of the syntax correct. The function is called 'Fill', the old array 'Old' and the new one 'New'. I'm using the name 'Block' for the passing-between variable name. So, the line ...

Access/VBA: Prevent moving to next record when hitting Enter?

I have a form in Access 2003 that should only be working with a single record. I can set the Cycle property to Current Record, but the form still jumps to the next record when I press Enter. My first thought was a KeyPreview property, but I'm not seeing one. My other thought is maybe the KeyPress or KeyUp event, but I thought I'd ask ...

VBA UserForm Object

Hi, I'm really struggling with something here. I have a class module, let's call it FormMan which has a bunch of methods relating to the large number of userforms I have in my project. One particular method is to be called from a lot of different places and is pretty simple - it simply adds a user defined number of controls to a form and...

Weird Bug: "DoCmd.OutputTo acOutputQuery" is deleting the query

Has anybody encountered this problem that DoCmd.OutputTo acOutputQuery deletes the query itself, the second time it is run? Is there any workaround/patch for this bug (at least seems like a bug to me)? Is there a better way to do this? ...

Excel 2003 VBA Server Processing and Remote Desktop Connection

Hi Guys and Girls, apologies if this isn't considered right for SO but we have a strange problem with processing Excel Macros on our servers. We have over 100 excel spreadsheets which are created overnight on our server by WebFOCUS which are all formatted by macros. The spreadsheet is created using a template, the macro runs and then ...

How can I add a picture into a placeholder using PowerPoint 2003 VBA?

I am trying to create PowerPoint slides using MATLAB. It seems like it is basically the same as using VBA to create PowerPoint slides, except with slightly different syntax. The function and variable names are all the same. Anyway....I can add a picture to a slide. I can also add a specific layout, which creates some placeholders. But I...

Running Access QueryDefs from VBA in Word

I'm creating parameterized queries in Access and would like to call them from ADO code in a VBA module in Word. I'm not sure of the syntax, however, to call parameterized queries. Can't seem to find a good code reference online. If I have qryGetRecordByFirstLast that accepts Firstname and Lastname as parms, how do I code this execute in...

VBA - Check for active internet connection

Wrote a small app that accesses a bunch of search websites and puts the results in a word document, which gets run a few hundred times a day. It saves individual search results in a number of local folders so the next time those words are searched, it grabs them locally instead of loading the website again. This works fine - even thoug...

Opening semicolon delimited CSV file with VBA in Excel 2000

How does one open a semicolon delimited CSV file with VBA in Excel 2000? In Excel 2003 11.8231.8221 SP3 with VBA 6.5.1025, I can open a semicolon delimited file with the following VBA code: Workbooks.OpenText filename:=myFilename, _ DataType:=xlDelimited, Semicolon:=True, Local:=True However, when the same code is run in Excel 20...

List files of certain pattern using Excel VBA

How to list all the files which match a certain pattern inside a user specified directory? This should work recursively inside the sub folders of the selected directory. I also need a convenient way(like tree control) of listing them. ...

How can I return the results of a function to a cell in Excel?

Suppose I have a function attached to one of my Excel sheets: Public Function foo(bar As Integer) as integer foo = 42 End Function How can I get the results of foo returned to a cell on my sheet? I've tried "=foo(10)", but all it gives me is "#NAME?" I've also tried =[filename]!foo(10) and [sheetname]!foo(10) with no change. ...

MS Access Application - Convert data storage from Access to SQL Server

Bear in mind here, I am not an Access guru. I am proficient with SQL Server and .Net framework. Here is my situation: A very large MS Access 2007 application was built for my company by a contractor. The application has been split into two tiers BY ACCESS; there is a front end portion that holds all of the Ms Access forms, and then on ...

Pivot Table Grand Total at the top

We have an Excel spreadsheet with the Grand Totals at the top using a Forumla, but this isn't on the actual Pivot Table it's just in the spreadsheet. We have a client that wants the Grand Totals at the top of the Pivot Table and doesn't want us to use Formula. Does anyone know if this is possible (even using VBA or something, just so lo...

Modeless MsgBox, Error trapping, .Find

I have a subroutine that searches for an occurrence of a string in another workbook. I'm trying to get an error message to pop up if the string can't be found (it's most likely due to spelling mistakes), as vbModeless, and allows to user to click on the cell in the searched sheet with the correct value. Then I'd like to resume the search...

DLast equivalent in .Net

In Microsoft Access, there is this DLast function that returns the application key of the last value from a specified set of records. I wonder what is the equivalent of DLast in .Net that enables me to retrieve the primary key of my last insert? I am using Access over OLEDBConnection ...

Assign on-click VBA function to a dynamically created button on Excel Userform

I'm creating buttons dynamically on an Excel userform with the following code: With Me.CurrentFrame.Controls.Add("Forms.CommandButton.1") .Caption = "XYZ" .name = "AButton" .Font.Bold = True .ForeColor = &HFF& ... blah blah blah End With I'd like to assign a function to run when these buttons are clicked, but I can...

What is the best way to access a serial port from VBA?

What is the best way to access a serial port from VBA? I have a need for some of our sales reps to be able to send a simple string over the serial port from an action button in PowerPoint. I don't commonly use VBA, especially for anything like this. Normally I would turn it into an application of some sort, but I actually don't think th...

What causes Visual Basic Run-time error -2147319765 (8002802b) in Excel when an ActiveX control has been instanced?

I have created an ActiveX control using C++. I use Visual Basic code to instance the control in an Excel worksheet. I can only run the VB script once, subsequent runs cause the following runtime error when attempting to access the 'ActiveSheet' variable: Microsoft Visual Basic Run-time error '-2147319765 (8002802b)': Automation erro...