vba

Speed up pivot table filtering VBA code

I have a pivot table with a pivot field and contain many items. I've VBA code logic to decide if the pivot value should be visible or not. The problem is excel recalculates pivot table for each field shown or hidden which makes it very slow. I would like something where it recalculates only once, after all the values are set. I tried usi...

Reading Formatted Text from PowerPoint Programatically

I use something like this to get the text from a shape inside PowerPoint: s = ActiveWindow.Selection.SlideRange.Shapes("rec1").TextFrame.TextRange.Text However, if the text has bold, underlined, resized (etc) text within the shape (meaning only certain words or phrases inside the shape), the .Text property converts it all to plain tex...

How do I insert a SQL Server result multiple times in a live word document using VB

Ok, I'm stuck trying to figure out how to take a mail merge, use that info to make MS SQL calls and get strings back in a word document. I'm guessing VB but I have no VB experience. ...

email using Access and VBA without MAPI

I would like to send email from Microsoft Access unattended using VBA. I understand that the built-in method “SendObject” uses MAPI meaning security prompts and something like Outlook configured. Since I want to use the Task Scheduler to kick off different reports, I’m leaning away from MAPI and would prefer some other solution. Not a...

Excel VBA print to specific printer tray

In Excel (2007) VBA how do I print the worksheet to a specific printer tray? This will just print to the default tray on the printer: ws.PrintOut ActivePrinter:="\\print_server\printer_name" ...

How to add a menu item to the default right click context menu

I am attempting to do this using an MS Access 2003 application using VBA. I would like to right click on an MS Access form and have the default menu appear, as well as some options I want to add. I would like the added options to execute some function when clicked. Any ideas? ...

What is the best way to permanently mark a record as read-only?

I have an Access 2003 app that connects to a SQL Server 2000 box. I have a table in which I need to lock down a record along with all related records in different tables. By "lock down", I mean mark them as read-only so that no clients can edit those records unless an admin unlocks them. Any ideas? ...

Excel 2007 VBA: Performance on SelectionChange event

Is there a way to improve performance in any meaningful way for the following VBA code in Excel? Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Me.Range("Group1"), Target) Is Nothing Then With wksData .Range("Group1Column").Value = Target.Column .Range("Group1Row").Value = Target.Row...

Is this lookup method possible in Access VBA?

I'm using Access 2007 connecting to a MS SQL db through ODBC. I have a table called 'bases' it looks like this: Name ID Site -------------------- Home 1 111 Work 2 111 Car 3 111 Castle 4 111 Store 1 222 Rest 2 222 Now the tricky part is that the only part of this tabl...

Excel Print Worksheets by Name

I've got an Excel 2007 Spreadsheet and I'd like to write a VBA procedure to print particular worksheets by name. How do I do this? For example, I'd like to print "FirstSheet","ThirdSheet", and "FourthSheet" but not "SecondSheet". ...

Is there any reason to use ENUM's in VBA ?

I have tried to use ENUMS in my code for Access 2007. But it's very uncomfortable. May be it's better to use collections ? My code isn't working is such way I thought it would be useful. Public Function GetEnumId(Name As String, ReferenceTable As String) As Long Dim rs As DAO.RecordSet Set rs = CurrentDb.OpenReco...

Outlook - check email address type

I am trying to make a macro in Outlook that will scan the To: list for a certain text string, and spit out a message if all but one (or two, etc) addresses have it. Is there a simple way to do this? Essentially, I am trying to write something that'll avoid being able to send a restricted message to a bunch of people with the string 'xyz...

Link tables issue for Compiled Access (mde) file.

I have an old compiled Access Application mde file. This appication has linked tables to network shared folder. I tried to upgrade main database using upsizing wizard on main database and everything went well. Then when the aplication starts it gives error message that 'microsoft jet database engine cannot find the input table or query ...

Excel VBA to VB (DCOM)

I inherited an Excel VBA spreadsheet. I have been tasked to convert it to VB. The application acquires data from a PLC using a DCOM object (I think). The following code runs the sub SBR1Select when MX1.0 is updated. Sub Workbook_Open() ActiveWorkbook.SetLinkOnData "dassidirect|strandburner!MX1.0", "SBR1Select" End Sub When I op...

Transferring Rich Text data from Access to Word

I've been saddled with supporting an old Access 2003 database (with SQL backend) produced by a now out-of-business contractor. The database includes several 'unconventional' reports. They all use Automation through VBA to output fields directly to a Word document. Kind of like this (pseudo code): for each row{ output(row.id); ...

Read values from the Office 2007 ribbon using VBA

Using VBA, can I find out the value of a text (combobox) control on the Word 2007 ribbon? Say I'd want to read the currently selected font name in the "Home" tab. I've seen an example using the IAccessible interface to do some interaction with the Ribbon (namely enumerating it), but it seems reading a control value is not possible. Is ...

How to Transfer Large File from MS Word Add-In (VBA) to Web Server?

Overview I have a Microsoft Word Add-In, written in VBA (Visual Basic for Applications), that compresses a document and all of it's related contents (embedded media) into a zip archive. After creating the zip archive it then turns the file into a byte array and posts it to an ASMX web service. This mostly works. Issues The main issue ...

Multiple developers in a VBA project

My understanding of VBA is that one office document contains a suite of VBA functions, all stored within the same file as the data. Is it possible to have more than one developer modify this code at once? In a conventional software development project, the code is distributed amongst multiple text files. Developers can modify and check...

What to use in creating a hand held database application

What program/programming language would be ideal for creating an Access like database on a Windows 5 CE hand held scanner? We have tried Visual CE but it is not really something we can work with. Ultimately we would love to build a system where we scan a bar code, select a user from a drop down list, select basic options of division, l...

No Dangling Word Headings Between Page Breaks?

Does anyone have a good VBA way (or perhaps there is an MS Word setting I can't find) to make sure that Word headings do not dangle at the end of a page. For example, assume that the numbers on the left are page numbers. 1 This is the second to last line on the page. 1 HEADING 1 2 This text starts page two What I want to do is au...