vba

How to create variables from strings in arcobjects?

This hopefully is a simple question with a simple answer. If I have a list box or something that has a list of like 4 years (like 2006 through 2009), how do I programmatically make variables of these years with names like pTable2006, pTable2007, etc (as ITable of course). If this isn't possible and I have publicly declared these tables...

enumerate queries in sheets of an excel workbook

I need a vba macro to enumerate the queries on each worksheet of a workbook. Can you provide example code? Jerry E ...

"User-defined type not defined" for Excel Range Using Late Binding In Access 2003

Hello, I am trying to write a VBA script which imports all of the Excel files in a folder into a table in Access 2003, first checking if they have been imported or not. That part is fine. The issue I run into is clearing out some of the formulas that don't get used on the spreadsheet which causes difficulty when Access tries to import t...

Getting Information from a Shell'ed Process into the VBA Program

So, let's say that I have a VBA application inside of whatever Office Application. I have created a command-line VB.net program to do all of the fun web-services stuff. Okay, the VBA application calls Shell() to run the command line program. Now, what is the best way to get information (a tracking number for a package) from the VB.net p...

MS Access 2007/2003 - Referencing a control on a sub form, from the parent form

So if I want to reference a control (like a text box) on a sub form, from the CBF of the parent form, how should I do this. me.SubForm.SubControl gives me an error. thanks justin ...

Is there a direct way to get the index of a slide in a PowerPoint presentation?

I am trying to programmatically copy a slide in a PowerPoint presentation, and paste it right after the original. My first thought was to get the index of the old slide, and add the copy at the desired new index, but I can't seem to find a straightforward way to retrieve that index. I expected to have something like Slides.IndexOf(Slide...

Export data from Access to Excel without losing leading zeroes

I have a table in Access I am exporting to Excel, and I am using VBA code for the export (because I actually create a separate Excel file every time the client_id changes which creates 150 files). Unfortunately I lose the leading zeroes when I do this using DoCmd.TransferSpreadsheet. I was able to resolve this by looping through the re...

Open an html page in default browser with VBA?

How do I open an html page in the default browser with vba? I know it's something like: Shell "http://myHtmlPage.com" But I think I have to reference the program which will open the page...Help! Thank you! ...

Adding a '%' after each value automatically

I'm not a huge fan of formatting cells as a percent in Excel because it automatically multiplies the value by 100. I want to write my own VBA function that looks for a change in value in a particular cell and adds a '%' to the end of it. How can I write some code to look for changes automatically? ...

Excel VBA ListRows.Add Fails

I'm probably missing something simple, but ListRows.Add is giving me grief. Here's the function: Sub addEmployee(employeeName As String, tableToAddTo As ListObject) Dim newRow As ListRow Set newRow = tableToAddTo.ListRows.Add() newRow.Range.Cells(1, 1).Value = employeeName tableToAddTo.Sort.Apply End Sub In most cases, t...

sql access how to return between dates

How do I specify a date range in MS Access? Is the below query correct? Do I have to put "2/1/2010" in quotes? Or do I have to do something like date(2/1/2010)? SELECT [Occurrence Number] as Fld FROM [Lab Occurrence Form] WHERE [Practice Code]="ACCIM" AND [1 0 Preanalytical (Before Testing)]="1.1 Specimen Mislabeled" AND ([Occu...

Trim null characters from a string in VBA

I'm calling a Win32 API function and getting back a string padded with null characters. Trim$() doesn't remove them. Is there an easier solution then removing them one character at a time? ...

Implementing my own interface in vba always raise this error !!!

how to Implements my class 'ClsInterface' which have this code Public Function add(x As Integer, y As Integer) As Integer End Function in my class 'Class2' which have this code Implements ClsInterface Public Function add(x As Integer, y As Integer) As Integer add = x + y End Function my test code is Public Sub test() Dim obj As N...

pivot table in userForm in excel vba

Dear All, Any idea about how to embed/insert pivotTable/pivotChart in a userForm? *code sample will be great to share. 1000,000 thanks in advance ...

Breakpoints cause PowerPoint 2003 Add-In to crash

I am writing an Add-in for Powerpoint 2003 using Visual Studio 2008. I created it by selecting "New Project" in Visual Studio, then choosing the "PowerPoint 2003 Add-in" project template. I added a simple menu to PowerPoint which opens a simple windows-form. If I put a breakpoint into the Add-in code which creates the menu (code which...

sorting a listbox in VBA

I have a listbox with values. Now I need to sort that listbox, BUT NOT BY ALPHABETICALLY. You see the values in a listbox are from a table. ------------------------ | name | order | size | ======================== value1 4 value2 3 value3 1 value4 2 I hope I made myself clear. So the list box has the items "value1, va...

MS Access 2003/2007 - Passing data through a variable on unbound forms vs. a hidden text box

Ok so I hope the title of the question matches what I about to ask, but here is what I am trying to get at: So I have an access database that uses a number of unbound forms, and the purpose of the forms are to collect data and save to various tables with VBA click events using SQL statements (INSERT or UPDATE based on whether the ID of ...

selecting all cells in excel sheet from an offset (VBA)

So I am creating an excel report from an access database. So this is done in access VBA. Here is my code: Public Sub ExportActiveSheet() 'irrelevant data 'get the info ExcelSheet.Range("A3").CopyFromRecordset rs Set rs = Nothing End Sub so now, as you can see.. my recordset gets copied to a range starting from A3. ...

Generate word documents from excel file using mail merge

Hello I am trying to generate word documents using the mail merge feature in Microsoft Word. To be as clear as possible my dream would be to: (1) Place all values for all documents to be created in one excel document (2) Use Word to create a template by selecting the above excel file as the data sheet (3) Run a macro that would use th...

Is it possible to run a macro in Excel from external command?

Let's say I want to program a VBA code in an external program that opens an Excel file, runs a macro, saves (and say yes to any pop up windows), and close Excel. Is it possible to do so? If so, how would I go about implementing it? ...