vba

If DoCmd.SendObject fails?

I am using DoCmd.SendObject to send emails from MS access 2003. It opens the outlook with all relevant fields filled. But the user may not choose to send the email at that time. In that case, a prompt 'Send Action was cancelled' appears. Is there a way to catch this non-sending of email by user ...

Chart on MS Access 2003 ADP report

What's the best method of displaying report data in a chart format in an Access 2003 ADP project? I know this can be done in normal MDBs but this seems to use a Jet Crosstab query behind the scenes and this is not available in the ADP. I've experimented with the Office 11 Chart control but this seems a bit hit and miss. ...

Is there a way in VBA to know about variables that aren't being used?

Is there a tool, method or setting in VBA to warn about variables that have been DIMmed, but aren't being used? ...

Using tables in UDF's in Excel 2007

I am writing a UDF for Excel 2007 which I want to pass a table to, and then reference parts of that table in the UDF. So, for instance my table called "Stock" may look something like this: Name            Cost            Items in Stock Teddy Bear    £10              10 Lollipops         20p              1000 I have a UDF ...

How do I protect all worksheet in an Excel workbook with a single click?

I have around 25 worksheets in my workbook (Excel spreadsheet). Is there a way I can protect all the 25 worksheets in single click ? or this feature is not available and I will have to write a VBA code to accomplish this. I need very often to protect all sheets and unprotect all sheets and doing individually is time consuming ...

Why does declaring content as a string cause WinHttp to not send HTTP content in Excel VBA?

I have an Excel VBA macro which does the equivalent of the following HTTP POST which works successfully: Set WebClient = CreateObject("WinHttp.WinHttpRequest.5.1") ' ... Configure WebClient for a POST request RequestBody = "<request>" WebClient.send RequestBody Previously, I had explicitly set the type of RequestBody as a String as in...

Creating Recordset in VBA wit SQL statement

I am trying to create a recordset in Access VBA that will show me all records in a table related to the current record of a form. My current code looks like this: Private Sub Form_Load() Dim rst As Recordset Set rst = CurrentDb.OpenRecordset("Select [ID], [Ln] From [Order Detail] Where ((([Order Detail].[ID]) = [Forms]![Order...

How to find full path of Outlook .pst file?

Is there a way to programmatically find the location of the current user's Outlook .pst file(s) through an API call or registry entry? ...

Extracting Source Code from an MS Access DB

Hi, I have an Access DB that I would like to extract the source code from so I can put it into Source control. I have tried to extract the data using the Primary Interop Assemblies(PIA), but I am getting issues as it is not picking up all of the modules and forms. There are 140 Forms and Modules in the code(Don't ask, it's a legacy ...

Writing VBA in Excel 2007 for use in Excel 2003

Where I'm at the developers have been updated to Excel 2007, but most of the users haven't. I'm building a spreadsheet template (*.xlt) for a user that's gonna need some vba code included, and I'm wondering what issues I'm likely to run into building this in 2007 instead of 2003? I don't have access to a machine with Excel 2003 for tes...

How do you test running time of VBA code?

Is there code in VBA I can wrap a function with that will let me know the time it took to run, so that I can compare the different running times of functions? ...

Escaping ' in Access SQL

I'm trying to do a domain lookup in vba with something like this: DLookup("island", "villages", "village = '" & txtVillage & "'") This works fine until txtVillage is something like Dillon's Bay, when the apostrophe is taken to be a single quote, and I get a run-time error. I've written a trivial function that escapes single quotes - ...

Making Excel functions affect 'other' cells

Let's say that I create a Sub (not a function) whose mission in life is to take the active cell (i.e. Selection) and set an adjacent cell to some value. This works fine. When you try to convert that Sub to a Function and try to evaluate it from from spreadsheet (i.e. setting it's formula to "=MyFunction()") Excel will bark at the fact...

CSV date format [VBA]

Hello I have a VB application which extracts data and creates 3 CSV files (a.csv, b.csv, c.csv). Then I use another Excel spreadsheet (import.xls) to import all the data from the above CSV files into this sheet. import.xls file has a macro which opens the CSV files one by one and copies the data. The problem I am facing is the dates in...

Macron in VBA editor

Been creating a simple program using VBA that I can use to review vocabulary in Chinese. I've gotten a fair bit working so far, but have run into a huge problem with inputting a macron-character such as "ā" (unicode 257). The specific application I am working on right now involves changing the contents of the text-box form so that an "...

VBA watch file in use

I"m looking for something (Win API calls or whatever) to notify me when a file becomes available for editing (i.e. no longer in use). Should I set up a timer to check the files on some interval or is there a good way to set up a watch on the file? ...

Examples of Optimization in VB/VBA/VB.net?

Please post examples of optimization done in VB/VBA/VB.net? Optimization can be in the context of performance or space/maintainability. Edit: Please specify somewhere in your post which environment you know your technique works in. Thanks. ...

How to check for empty array in vba macro

I want to check for empty arrays. Google gave me varied solutions but nothing worked. Maybe I am not applying them correctly. Function GetBoiler(ByVal sFile As String) As String 'Email Signature Dim fso As Object Dim ts As Object Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.GetFile(sFile).OpenAsTextS...

How to purge my junk mail folder of messages in the Cyrillic alphabet (Outlook 2007)?

Recently, my junk mail folder has been filling up with messages composed in what appears (to me) to be the Cyrillic alphabet. If a message body or a message subject is in Cryillic, I want to permanently delete it. On my screen I see Cyrillic characters, but when I iterate through the messages in VBA within Outlook, the "Subject" proper...

VBA for MS word

There are a lot of free sources to learn about the object model of MSExcel but I failed to find any comprehensive source for a similar source for MS word. Can You suggest a free and comprehensive source for the same? ...