vba

User Defined Type (UDT) As Parameter In Public Sub In Class Module.Visual Basic 6

I've tried to solve this problem, but can't find any solution. I have a UDT defined in a normal module, and wanted to use it as parameter in a Public Sub in a Class module. I then get a compile error: Quote: Only public user defined types defined in public oject modules can be used as parameters or return type for public procedures of ...

Visual Studio Macros

I am creating a Visual Studio Macro and I want it to take the data it is generating and export it to SQL. I can't seem to find a good way to connect to a database from Visual Studio's VBA. Does anyone know of a good way to do this? I am running Visual Studio 2008 and SQL Server 2008. Thanks for any help ...

SendMessage from VB6 app to Excel dialog box

My employer has purchased a third-party tool, OfficeConverter from Conveter Technology that automates the conversion / repair of Office 2003-formatted files to Office 2007 format. This tool also highly automates the translation / change in macro / VBA code requirements between Office 2003 and 2007 formats. My problem is that during thi...

Easy way to find cell reference in excel vba

Hi, I am working on a spreadsheet with lots of VBA code in it. Most cell references use numbers, e.g. Worksheets("Sheet1").Cells(someRow, someColumn) I am wondering if there is any easy way to find out exactly which cell is being referenced - is it possible to put a breakpoint on this line of code, and then see which cell it will ref...

What could cause Shape.Cut to fail in Excel VBA?

Hi all, I have a method in my macro that executes the following code: Set myDocument = Worksheets("sheet1") For each sh in myDocument.Shapes If sh.Name = "square" Then sh.Cut End If Next My problem is that the code causes an error on the line sh.Cut. I know that there is a shape called "square" - I can see (visually) ...

Excel page breaks via VBA

As part of an overhaul of a report generator I saw what I believed to be inefficient code. This part of the code runs after the main report is generated to set the page breaks in logical positions. The criteria is this: Each Site starts on a new page. Group's aren't allowed to broken across pages. The code follows the above format: 2...

How do I bind a macro to a key in Word 2007 without recording a new macro?

As the title so eloquently put it, I need to know how (or if it's even possible) to bind a macro to a key in Microsoft Word 2007 without recording a new macro each time. I find myself writing new macros directly in code and then not being able to bind them to a key. Or I might just want to rebind a macro to another key. ...

how to pass string array from C/C++ dll to vba (Excel)

how to pass string array from C/C++ dll to vba (Excel) dll in Visual Studio dll is not managed, ATL, etc. regards Andy ...

Copying a record in VBA

I work with a product that comes in a 2000lb sack and placed on a pallet. When this product is made it has many different elements that are tested and each test has a field that the numerical data is placed in. Each of these records of tests are then assign a number, for example, L20444. Now we have the ability to take that 2000lb sack...

Fonts look different when inserting Excel table in a Word document

Hi Folks, I am trying to use a VBA macro (for Office 2003) to do the following: In Excel, the user will select a range of cells In Word the user will call the macro (via a button or shortcut) to insert the selected Excel range as an embedded object The code is not the problem so far, my problems are: Given that the user is working...

Difference between Visual Basic and VBA

What is the difference between the two. I always thought VBA is somewhat 'crippled' version of VB, but when a friend asked me the other day I had no idea what the actual differences are. Also, when you use, for example, Excel, is that VB or VBA ? ...

Problem adding validation list in excel sheet using VBA

I have an excel sheet that is loaded with a dynamic result set of data. I need to add a YES/NO dropdown at the end of each row once all the data is loaded. I have to do this dynamically as I do not know the size of the result set beforehand. The following code throws an 'Applicaton-defined or object-defined error': Dim firstRow As Integ...

Excel 2007 conditional formatting - how to get cell color?

Hi, Let's assume i have the following range from (a1:c3) A B C 1 -1 1 1 2 -1 0 0 3 0 0 1 Now i have selected the following range, and formatted it using Conditional Formatting (using default red yellow green color scale).... now range colors became A B C 1 Green Red Red 2 Green Yellow Yellow 3 Yellow ...

Word macro, storing the current selection (VBA)

Hi, I have a Word document that contains about 4000 form fields which I have to export afterwards to a database. The matter is that none of the 4000 fields have an information in the "Bookmark" field, thus I cannot get the information stored in them. I'm trying to create a macro to help the process of writing the bookmark (FormField.Nam...

Copying a record in VBA 2 (the new question)

I have this code that I am trying to copy a record with in VBA. Unfortunately I cannot get it to work. I do not knw why it won't do anything. Dim OldRecord As DAO.Recordsets, NewRecord As DAO.Recordset Dim strSQL As String strSQL = "SELECT [Tote Log].* FROM [Tote Log] WHERE Number = " & _ Me.tbScannerRead.Value Set OldReco...

How to send mailmerge and add an attachment via VBA

I want send an mailmerge word document based on a query from Access database and also add a separate attachment (pdf) and email the merged document as the body of the email and the pdf file as an attachment ...

Detecting changes to checkboxes via VBA

Following on from my previous question. A requirement from the customer is to have checkboxes on a report to disable rows of information on another sheet. The rows are defined as named ranges, formated by P_XXXXXX. The XXXXXX is a unique identifier that is also a field on the row so I can easily generate the range names on the fly. The...

Is it possible to alter a marked field´s field function with Word 2007 VBA?

Hi, i want do the following: In Word 2007 place the Cursor on a field (or mark that field) and call a macro wich edit the field function of that field. (add some string). I´m even grateful for some tipps what term to google. I used the macro recorder and got following: WordBasic.FormatField Field:="CITATION Gro05 \p 9 \l 1031" Th...

How can I connect to Lotus thru ODBC using VBA?

I'm interested in setting up an Access db to run a report automatically. To save myself the trouble of going to each client computer and setting up the appropriate DSNs, I'd like to set up the ODBC connections in the VB script itself if possible. I've googled and checked this site and found some good starter code, but not enough to ma...

Show code from from thru code (in ms access)

making an Access database (2003) that is mainly used by other programmers and tech management as a tool for data validation. I want to put an button on parts of the form that runs code, to show the code that is being run. So the programmers can edit it on the spot. This is for a data validation project with frequent changing of code. ...