Skip to content

Instantly share code, notes, and snippets.

@tdalon
tdalon / SetLang.bas
Created June 28, 2016 07:51
PowerPoint VBA: Set Presentation Language (supporting grouped objects and SmartArt)
Option Explicit
Sub SetLangUS()
Call changeLanguage(ActivePresentation, "US")
End Sub
Sub SetLangUK()
Call changeLanguage(ActivePresentation, "UK")
End Sub
@tdalon
tdalon / MoveSectionsSelectedBySlides.bas
Last active September 22, 2016 08:48
PowerPoint VBA: Move sections selected by slides
Sub MoveSelectedSections()
' Slides are copied ready to be pasted
Dim lngNewPosition As Long
'Debug.Print ""
'Debug.Print "###Move Sections..."
lngNewPosition = InputBox("Enter a destination section index:")
lngNewPosition = CInt(lngNewPosition) ' Convert String to Int
Call MoveSectionsSelectedBySlides(ActivePresentation, lngNewPosition)
End Sub
@tdalon
tdalon / EditorGetFile.m
Last active October 10, 2016 18:37
Get current file opened in MATLAB Editor
function file=EditorGetFile
% EditorGetFile get current file opened in Editor
%
% SYNTAX:
% file=EditorGetFile
% OUTPUT:
% file (char): fullpath
edhandle = com.mathworks.mlservices.MLEditorServices.getEditorApplication;
file = edhandle.getActiveEditor.getDocument.getFilename;
@tdalon
tdalon / UpdateAllFieldsTOCWithoutTracking.bas
Last active October 18, 2021 21:11
MS Office Word VBA Macro to update all fields including in header and footer also update Table of Contents. Tracking Changes is disabled during the update.
Sub UpdateAllFieldsTOCWithoutTracking()
' Update All Fields and TOC without Tracking Changes for it:
' References:
' http://www.gmayor.com/installing_macro.htm or
' http://stackoverflow.com/questions/33733113/macro-to-update-all-fields-in-a-word-document
' http://gregmaxey.mvps.org/word_tip_pages/word_fields.html
' http://vba.relief.jp/word-vba-toggle-track-change/
Dim oStory As Range
Dim isChangesTracked As Boolean
function [opt, callstr] = plot_depfun(foo,varargin)
% PLOT_DEPFUN plots a call graph tree of the function dependencies
% SYNTAX
% plot_depfun(foo,varargin)
%
% Ignores MATLAB function in matlabroot and any function names given in varargin.
% Uses current file in MATLAB Editor as default if no argument is passed or first argument is empty.
%
% See also depfun, mydepfun, plot_subfun (file exchange ID 46070)
@tdalon
tdalon / TextBox_Search_KeyDown.bas
Last active September 27, 2016 12:03
PowerPoint VBA TextBox KeyDown Callback
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
' https://tdalon.blogspot.com/2016/09/powerpoint-quick-search-tagged-slides.html
' References: http://stackoverflow.com/questions/26587114/powerpoint-search-box-vba
' Hidden Search TextBox
Dim osld As Slide
Dim oshp As Shape
Dim sTextToFind As String
If KeyCode <> 13 Then 'ENTER PRESSED
@tdalon
tdalon / myquestdlg.m
Created September 28, 2016 19:32
MATLAB Modified questdlg to solve bug
function ButtonName=myquestdlg(Question,Title,Btn1,Btn2,Btn3,Default)
%MYQUESTDLG Question dialog box. Same as QUESTDLG plus solves the issue that if user press ENTER
% it will return the Default Button and not the selected one.
% See http://tdalon.blogspot.com/2016/09/matlab-bug-questdlg.html
% Moreover the dialog window is now properly centered in the middle of the screen.
%
% SYNTAX:
% ButtonName=myquestdlg(Question,Title,Btn1,Btn2,Btn3,Default)
% OUTPUT
% ButtonName (char) is empty if User ESC the dialog.
@tdalon
tdalon / UpdateAllFields.bas
Created September 30, 2016 06:23
Update All Fields Macro for MS Office Word
Sub UpdateAllFields()
'
' UpdateAllFields Macro
'
'
Dim oStory As Range
Dim oField As Field
For Each oStory In ActiveDocument.StoryRanges
For Each oField In oStory.Fields
oField.Update
@tdalon
tdalon / DeleteEmptyParagraphs.bas
Created September 30, 2016 06:24
MS Office Word VBA Macros to delete empty paragraphs
Sub DeleteEmptyParagraphs()
Dim oPara As Word.Paragraph
For Each oPara In ActiveDocument.Paragraphs
If Len(oPara.Range) = 1 Then oPara.Range.Delete
Next
End Sub
Sub DeleteEmptyParagraphsWithSpaces()
Dim oPara As Word.Paragraph
Dim var
@tdalon
tdalon / CheckReminders.bas
Last active December 3, 2021 21:10
Outlook vba to check appointment reminders
Sub CheckTodayReminders()
' https://www.datanumen.com/blogs/quickly-send-todays-appointments-someone-via-outlook-vba/
Dim objAppointments As Outlook.Items
Dim objTodayAppointments As Outlook.Items
Dim strFilter As String
Dim objAppointment As Outlook.AppointmentItem ' Object
Set objAppointments = Application.Session.GetDefaultFolder(olFolderCalendar).Items
objAppointments.IncludeRecurrences = True
objAppointments.Sort "[Start]", False ' Bug: use False/descending see https://social.msdn.microsoft.com/Forums/office/en-US/919e1aee-ae67-488f-9adc-2c8518854b2a/how-to-get-recurring-appointment-current-date?forum=outlookdev