Archive for the 'Uncategorized' Category

TFS in Excel: Exporting Charts Using VBA

Problem You want to automate the exporting of a chart within an Excel worksheet to a PNG image file using a VBA macro. Solution Private Sub ExportChartToFile(Worksheet as String, ChartNumber As Integer, Filename As String) Dim objChrt As ChartObject Dim myChart As Chart Dim FilePath As String Set objChrt = Sheets(“Worksheet”).ChartObjects(n) Set myChart = objChrt.Chart […]

iOS: Running Code on the Main Thread

Problem: In iOS, updating the user interface should be done in the main thread. However, many asynchronous methods invoke the callback on an arbitrary thread. How can I make sure a particular piece of code is run in the main thread? Solution: You need to use the grand central dispatch: dispatch_async(dispatch_get_main_queue(),^{ // The code to […]

UNC Paths in Windows Command Shell

Problem: Copy and other command shell commands don’t work with UNC paths, i.e. \\server\dir. Solution: Use pushd <path> to temporarily assign a drive letter and map it to the path. pushd \\server\rootfolder\subfolder When done, use popd to unmap the letter.