Archive for the Category » Stupid code tricks «

Monday, April 11th, 2011 | Author:

As strange as it seems in a globalized society, MS PowerPoint developers haven’t considered necessary to allow their users to change the language of a whole presentation. This becomes especially annoying when you translate your slides. You easily end up with a mix of languages on a slide, and you’ll notice, then, that it is not possible to select the main one: the language button (on the bar below) is simply not clickable if a multilanguage text is selected (in MS Word, this works, but NOT in MS PowerPoint). Even a mix between English/US and English/UK disables the button.

The basic roundabout consists in determining the “by default” language. Simply click the language on the language bar on some one-language slide where this actually works, select a language, and press “by default”:

MS PowerPoint - Language by default

Every new slide will systematically apply your the default language to any new box.

However, this doesn’t solve the problem of an existing presentation you wish to translate. Starting to write in English on a French slide, the auto-corrector will underline your spelling, perhaps even chew it up altogether if you have ‘correct as you type’ active. If you are lucky, the language chooser button works. But even a simple mixture of french-fr and french-chmakes it impossible to use it.

Then, how do you determine the language of a whole slide? Or even (woaw) the language of a whole presentation?

Well, the only way to go around this is a macro (!) I’ve got from Chocotooth’s blog:

Sub SetLangUS()
Dim scount, j, k, fcount
scount = ActivePresentation.Slides.Count
For j = 1 To scount
fcount = ActivePresentation.Slides(j).Shapes.Count
For k = 1 To fcount 'change all shapes:
If ActivePresentation.Slides(j).Shapes(k).HasTextFrame Then
ActivePresentation.Slides(j).Shapes(k).TextFrame _
.TextRange.LanguageID = msoLanguageIDEnglishUS
End If
Next k
fcount = ActivePresentation.Slides(j).NotesPage.Shapes.Count
For k = 1 To fcount 'change all shapes:
If ActivePresentation.Slides(j).NotesPage.Shapes(k).HasTextFrame Then
ActivePresentation.Slides(j).NotesPage.Shapes(k).TextFrame _
.TextRange.LanguageID = msoLanguageIDEnglishUS
End If
Next k
Next j
End Sub

What should you do with this? Click the Visual Basic button on the ‘Developer’ tab:

 

Insert a new module by right-clicking on ‘VBAProject’ in the left navigation pane:

New module in Visual Basic

 

This opens a new window. Paste the code into it. And run it with the ‘play’ button:

Code Window in Visual Basic

See? All text boxes have been set to English/US. You can save this code for later use in a file with .bas extension.

PS: Dear Microsoft, if you could offer a less tedious solution than this by simply integrating the language-switching feature in PowerPoint, many thanks in advance.

Thursday, August 12th, 2010 | Author:
echo get_class($my_class_instance) . '<br/>';
foreach (get_class_methods($my_class_instance) as $method) {echo '--------->' . $method . '<br/>';}
Thursday, August 12th, 2010 | Author:

To stock ‘machine readable’ information about a table cell use the abbr tag:

<td abbr="my_data">

Might come in handy for example when you try to give jQuery a handle on specific table cells when id and class tags are already in use.

The ‘abbr’ attribute is an official attribute of the td tag in HTML 4.01/XHTML 1.0 DTD in compliance with S=Strict, T=Transitional, and F=Frameset.

Thursday, August 12th, 2010 | Author:

Sometimes, stuff gets stuck in Windows trash. Mouse-click trash emptying doesn’t work any more.

If that happens, use the following DOS code in the command line:

rd /s /q C:\RECYCLER

If something’s really stuck in the recyler, you will get the following error message (or equivalent in your operationg system installation language):

Problem - Le processus ne peut pas accéder au fichier car ce fichier est utilisé par un autre processus

Ignore that message. The trash on the desktop, too, will still have the “full” icon but this wull be gone once you right-point it and ask the trash to be emptied.

Thursday, August 12th, 2010 | Author:

Trying to call R from, say Java?

C://Program Files/R/R.exe

returns an error as the Windows command line has trouble interpreting spaces.

Use this call instead:

C://program~1/R/R.exe