vba

Compile time: Syntax error

I am able to add controls to a form when it is loaded. I need these controls to be to be catagorized so the user only can see a few at a time. My first thought was to attached the controls to particular tabs. Not sure why the syntax is off in the following code. Thanks for the help! Private Sub Enter_Records_Click() Dim stDocName As St...

How to reassign the address of a named range in Open Office VBA?

In Excel VBA, I redefine the address of a named range with: Ranges("MyRange").Cells(1).CurrentRegion.Name = "MyRange" in the Worksheet_Deactivate event. This way, after updating the spreadsheet, MyDataRange always references to the entire data. Ok with Excel, but when I tried to migrate this to Open Office VBA (OpenOffice.org 3.1.1 /...

Excel - Worksheet_Activate Code for New Sheets

Hi, I have three questions about VBA and controlling/manipulating new windows. I have several sheets set up. Master | Worksheet1 | Worksheet2 | Notes | Work Orders | Contact Info 1) I have WorkSheet_Activate functions set up on Notes, Work Orders, Contact Info that open up all three sheets in seperate windows and arrange them vert...

How to remove the recent document history in Excel Ribbon using VBA

How to remove the recent document history in Excel Ribbon using VBA. I am using the code below, but it doesn't seems to work. Sub Button1_Click() For i = 1 To Application.RecentFiles.Count - 1 Application.RecentFiles(i).Delete Next i End Sub Thanks ... ...

how to use a macro to transpose data from rows into columns

I am totally new to VBA (aside from recording and running manually) so was hoping somebody could help me with designing this. I have a worksheet with unspecified # of rows per unique ID (column A), based on date and type. : A B C D 1 12Jan2010 type A Person1 1 16Jan2010 type B Person1 ...

Microsoft Excel – How to copy cells to a different worksheet on every nth row.

Microsoft Excel – How to copy cells to a different worksheet on every nth row. I have an interesting problem. It is probably simple, but I can’t figure it out. I have a list of cells (about 10 columns across and over thousand rows, soon to be expanding) A1-A10 and down These are my headings and main input cells (let’s call this Summary...

Excel VBA Programming with Arrays: To Pass them or Not To Pass them?

Question: I am wondering which is the optimal solution for dealing with Arrays in Excel 2003 VBA Background: I have a Macro in Excel 2003 that is over 5000 lines. I have built it over the last 2 years adding new features as new Procedures, which helps to segment the code and debug, change, or add to that feature. The downside is tha...

removing the nulls from an array and copying to new array

I am splitting a line of text into an array then attempting to put into a new array without the null spaces. For some reason it's not copying from the old array into the new one. BTW if someone has a more efficient way of doing this I am open to that as well. Dim x As Variant, i As Integer, m As String, rdate As String, k(0 To 50) As V...

Extracting unicode text from Excel spreadsheet using VBA

We generate HTML from text in an Excel spreadsheet. The text contains unicode representations of international characters. When we use VBA to extract the text and output it to a file, it is written as ANSI (ASCII). Is there a way to preserve the unicode representation using VBA? Bruce ...

Using Application.Run in Excel VBA when workbook name contains spaces

Hello, Application.Run "MyWorkBook.xls!Macro1" will work (run the macro called Macro1 in the MyWorkBook.xls file) Application.Run "My Work Book.xls!Macro1" will not (if the workbook name contains spaces, Excel says "the macro cannot be found"). I just spent hours figuring out that it's the spaces causing this problem... Is there ...

Excel, 2 sheets, 2 columns, same value?

Hi, I have 2 sheets sheet1 and sheet2 in an excel 2007 file. In sheet2 I have a column that is managed by a form/macro(with a tree view control). When an element has been selected, the cell is filled with an "x", when it has been unselected, the cell is filled with "" (nothing). In sheet1 I want to create a column equal to the sheet2 ...

MS Access 2003 - Having trouble with buttons not working in mde file: list box .rowsource

So I have a form that has a list box and several buttons that run sqk statements for the list box. sub on_onClick() ' error checking me.listbox.rowsource = "SELECT tblMain.First, tblMain.last FROM tblMain ORDER BY tblMain.Last;" so this kinda thing is what I use for the list box. it works fine for me in the .mdb, and after i have co...

Using Python to program MS Office macros?

I've recently taken it as a project to teach myself how to program in Python. Overall, I must say that I'm impressed with it. In the past I've typically stuck to programming in VBA mostly for MS Excel (but also a bit in MS Access and Word) and have struggled to find ways to make it do things that Python can easily do with a single comm...

Open excel 2007 excel files and save as 97-2003 formats in VBA

I have a weird situation where I have a set of excel files, all having the extension .xls., in a directory where I can open all of them just fine in Excel 2007. The odd thing is that I cannot open them in Excel 2003, on the same machine, without opening the file first in 2007 and going and saving the file as an "Excel 97-2003 Workbook"....

How do I access other fields in the current row in a query from a custom VBA function?

I would like to write some custom VBA functions to perform calculations on particular fields in a set of queries. This is what I currently have: Public Function TVM(LEN_SEC As Double, ADT_CUR As Integer, TRK_PCT As Integer) TVM = LEN_SEC * ADT_CUR * TRK_PCT / 100# End Function This works fine, but when I create the query I have to...

How can I work around the 2GB database limit of MS Access (for displaying images)?

ORIGINAL QUESTION (How can I display images from a MySQL database in an Access 2007 form?) I would like to use Access 2007 to interface to a MySQL database and display pictures and other data in a form. I already have an Access 2007 application that I don't want to change much, if I can help it. I'm just not sure what data type will w...

What is the maximum value for row and column Range offset in VBA/Excel ?

I am using microsft excel 2003. I am getting "Application-defined or object-defined error" while executing the following If statement. If Range("MyData").CurrentRegion.Offset(i, 0).Resize(1, 1).Value = Range("MyData").CurrentRegion.Offset(i + 1, 0).Resize(1, 1).Value Then The value of i is 58981 when I get this er...

Connecting to a MS Access database through a function

This is my function: Public Function DBConnection(ByVal path As String) ' This function makes the database connection and returns the object ' to reference it. cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + path + ";") cn.Open() Return cn End Function As you can see, I want to initializ...

Excel Word Wrap Problem after Macro

I have a macro that I use to receive data from an InputBox and then insert that data into a cell. I am having some formatting issues with the data after the following macro runs. Sub InsertNotes() ' ' insertnotes Macro ' ' Dim UserNotes As String UserNotes = InputBox(Prompt:="Please enter your note below:", Title:="Note input"...

How do I connect to a Lotus Notes DB through VBA?

I'm trying to connect to a Lotus Notes database via VBA in Microsoft Access 2003. The code I have is as follows: Set nSession = CreateObject("Notes.NotesSession") Set nDatabase = nSession.GetDatabase("CN=MT_N01/O=Org Name", "LossPrevention\BrchPrVI.nsf", False) I've tried variations for the server name, but nothing seems to work. In...