<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5344982184119705320</id><updated>2025-11-16T07:11:57.466-08:00</updated><category term="C#"/><category term=".NET"/><category term="Visual Studio"/><category term="VBA"/><category term="Comment"/><category term="WiX"/><category term="Caliburn.Micro"/><category term="Microsoft Office"/><category term="Code Contracts"/><category term="Rant"/><category term="AxoCover"/><category term="MVC"/><category term="Code Coverage"/><category term="Microsoft"/><category term="Microsoft Access"/><category term="The Reddick C# Style Guide"/><category term="Visual Basic for Applications"/><category term="WPF"/><category term="Excel"/><category term="Microsoft Word"/><category term="SBS"/><category term="StyleCop"/><category term="VBA Settings"/><category term="XAML"/><category term="ASCII"/><category term="Adobe Reader"/><category term="Assembly Attributes"/><category term="BOM"/><category term="Blogger"/><category term="Book"/><category term="Break Key"/><category term="Byte Order Mark Unicode"/><category term="CSS"/><category term="Calculator"/><category term="Cisco"/><category term="Color"/><category term="CompanyWeb"/><category term="Database"/><category term="Disable Javascript"/><category term="Disk Drive"/><category term="DiskPart"/><category term="Excel API"/><category term="Fonts"/><category term="GUID"/><category term="HP-16C"/><category term="HTML"/><category term="Hot Swapping"/><category term="ICE"/><category term="JavaScript"/><category term="Keyboard"/><category term="Little Bobby Tables"/><category term="MSI"/><category term="MSTest"/><category term="MSTestV2"/><category term="Macros"/><category term="Mastermind"/><category term="Microsoft Installer"/><category term="Names"/><category term="Office 365"/><category term="OpenCover"/><category term="Orca"/><category term="Outlook"/><category term="PowerPoint"/><category term="Powershell"/><category term="Product Failure"/><category term="Resharper"/><category term="Runtime errors"/><category term="SATA"/><category term="SBS 2008"/><category term="SSL"/><category term="SharePoint"/><category term="Small Business Server"/><category term="Status"/><category term="TypeScript"/><category term="UI"/><category term="UTF-8"/><category term="UX"/><category term="Unit Test"/><category term="User Interface Design"/><category term="VPN"/><category term="ViewPort"/><category term="Visio"/><category term="WiX MSI"/><category term="Windows 10"/><category term="guidgen.exe"/><category term="optimization"/><category term="switch statements"/><title type='text'>Greg Reddick</title><subtitle type='html'>Greg Reddick is a noted speaker, author, and software engineer. This blog covers all aspects of programming, particularly for Windows, and other related topics.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.xoc.net/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>106</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-1464534420126482854</id><published>2025-11-16T02:17:00.000-08:00</published><updated>2025-11-16T02:35:29.118-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="AxoCover"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Code Coverage"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio"/><title type='text'>Visual Studio 2026 Includes Code Coverage in Community and Professional!</title><content type='html'>&lt;p&gt;
  On a posting I made on 2014-02-03, I asked that Microsoft include code
  coverage in the Community and Professional editions of Visual Studio. In my
  opinion, it was the most glaring missing feature in those editions. They
  included it in their Enterprise edtion, but the cost was prohibitive.
&lt;/p&gt;
&lt;p&gt;
  In the 11+ years since, I have posted multiple times about it being missing.
  This was not a big work item, since most likely it just took flipping a
  variable in the Visual Studio build process to include it. There has been on
  open thread on the Microsoft Visual Studio feature requests site for about
  that long. At one point, Microsoft said they&#39;d never do it and closed the
  request, which caused a furious response by the several hundred people follow
  that thread. I think the response caused a reconsideration.
&lt;/p&gt;
&lt;p&gt;
  Well, it finally happened. Visual Studio 2026 includes code coverage in all
  editions. I would like to commend Microsoft for finally adding this feature. I
  noticed that on the page of new features, they put it right at the top, above
  all of the AI features they added to Visual Studio.
&lt;/p&gt;
&lt;p&gt;
  Code coverage is the tool that tells you what code is hit while it is being
  run. It is mainly used in conjunction with unit tests. It tells you what code
  your unit tests are not hitting. Having unit tests as a feature without code
  coverage as well makes makes it impossible to measure the comprehensiveness of
  your unit tests.
&lt;/p&gt;
&lt;p&gt;
  Check out the feature in
  &lt;a href=&quot;https://visualstudio.microsoft.com/downloads/&quot;&gt;Visual Studio 2026&lt;/a
  &gt;. Microsoft claims that they addressed over 300 feature requests in this
  version. I am sure some of the other ones are great, but code coverage has
  been at the top of my list for a very long time.
&lt;/p&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/1464534420126482854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2025/11/visual-studio-2026-includes-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/1464534420126482854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/1464534420126482854'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2025/11/visual-studio-2026-includes-code.html' title='Visual Studio 2026 Includes Code Coverage in Community and Professional!'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-4525897034867616630</id><published>2025-03-03T18:16:00.000-08:00</published><updated>2025-11-16T02:20:12.675-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>Where did the C# Programming Language Name Originate</title><content type='html'>&lt;p&gt;
  In the late 1980s at Microsoft, there was an attempt at constructing some
  extensions to the C++ programming language, which were internally named C#.
  This project failed, was cancelled, and never used. The database used
  internally by the language required more resources than the hardware that was
  available at the time could provide.
&lt;/p&gt;
&lt;p&gt;
  However, about a decade later when Microsoft again attempted to form a
  programming language, they recycled the name. This name is now used for one of
  the most popular programming languages. The name was meant to represent C++++,
  if you view the # sign as four plus signs. C++ means &quot;one better than the C
  programming language&quot;. C# means &quot;two better than the C programming language&quot;.
&lt;/p&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
  &lt;a
    href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5KzseKtXQzh_XyOr6bme8B5QHSKmGfnIRicgM1LSwb8CkwhCzx-88Wa-KO8we1EKAUWYcK2tuMfWNPSEyoGmFduomgSOtG5CynfMZGerRfB9U_VlZ8U6eu4IblIl3DVq-E7gaLn0KQkpz37cbtp9PltOiYhslyLEtpuKIpZiMCbXzcaQe44wnG0Xs84w/s3280/C%23ProgrammingLanguage.png&quot;
    style=&quot;display: block; padding: 1em 0px; text-align: center;&quot;
    &gt;&lt;img
      alt=&quot;&quot;
      border=&quot;0&quot;
      data-original-height=&quot;3280&quot;
      data-original-width=&quot;2551&quot;
      height=&quot;600&quot;
      src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5KzseKtXQzh_XyOr6bme8B5QHSKmGfnIRicgM1LSwb8CkwhCzx-88Wa-KO8we1EKAUWYcK2tuMfWNPSEyoGmFduomgSOtG5CynfMZGerRfB9U_VlZ8U6eu4IblIl3DVq-E7gaLn0KQkpz37cbtp9PltOiYhslyLEtpuKIpZiMCbXzcaQe44wnG0Xs84w/s600/C%23ProgrammingLanguage.png&quot;
  /&gt;&lt;/a&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/4525897034867616630/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2025/03/where-did-c-programming-language-name.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/4525897034867616630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/4525897034867616630'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2025/03/where-did-c-programming-language-name.html' title='Where did the C# Programming Language Name Originate'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5KzseKtXQzh_XyOr6bme8B5QHSKmGfnIRicgM1LSwb8CkwhCzx-88Wa-KO8we1EKAUWYcK2tuMfWNPSEyoGmFduomgSOtG5CynfMZGerRfB9U_VlZ8U6eu4IblIl3DVq-E7gaLn0KQkpz37cbtp9PltOiYhslyLEtpuKIpZiMCbXzcaQe44wnG0Xs84w/s72-c/C%23ProgrammingLanguage.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-5675468380512149821</id><published>2024-07-10T22:16:00.001-07:00</published><updated>2024-11-02T20:25:51.442-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="VBA"/><category scheme="http://www.blogger.com/atom/ns#" term="Visio"/><title type='text'>Changing a Picture in Microsoft Visio</title><content type='html'>&lt;p&gt;
  Visio doesn&#39;t give you a built in way to change the picture that you&#39;ve added
  to a diagram to another picture. But with some VBA code, you can perform the
  task.
&lt;/p&gt;
&lt;p&gt;
  First, you will need to add the code below. Press Alt+F11 on the keyboard to
  open the Visual Basic Editor. Click Insert &amp;gt; Module from the menu. Paste
  the code below into the module. Save your drawing as a Visio Macro-Enabled
  Drawing (with a .vsdm extension).
&lt;/p&gt;
&lt;p&gt;
  Then to change a picture to another picture, select it. Then press Alt+F8 to
  open the macros dialog. Select ChangePicture from the dialog and click Run. A
  dialog will open asking you for a file. Select the file and click OK. The
  picture will change without losing things such as connections to the picture.
&lt;/p&gt;
&lt;p&gt;
  Most of the code is just to open the dialog to ask for the filename. The
  main&amp;nbsp; task is to call the shape&#39;s ChangePicture method.&lt;br /&gt;
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
Option Explicit

Private Declare PtrSafe Function GetOpenFileName _
    Lib &quot;comdlg32.dll&quot; _
    Alias &quot;GetOpenFileNameA&quot; ( _
    pOpenfilename As OPENFILENAME) As Long

Private Declare PtrSafe Function CommDlgExtendedError _
    Lib &quot;comdlg32.dll&quot; () As Long

Private Type OPENFILENAME
    lStructSize         As Long
    hwndOwner           As LongPtr
    hInstance           As LongPtr
    lpstrFilter         As String
    lpstrCustomFilter   As String
    nMaxCustFilter      As Long
    nFilterIndex        As Long
    lpstrFile           As String
    nMaxFile            As Long
    lpstrFileTitle      As String
    nMaxFileTitle       As Long
    lpstrInitialDir     As String
    lpstrTitle          As String
    flags               As Long
    nFileOffset         As Integer
    nFileExtension      As Integer
    lpstrDefExt         As String
    lCustData           As LongPtr
    lpfnHook            As LongPtr
    lpTemplateName      As String
    &#39;#if (_WIN32_WINNT &amp;gt;= 0x0500)
    pvReserved          As LongPtr
    dwReserved          As Long
    FlagsEx             As Long
    &#39;#endif // (_WIN32_WINNT &amp;gt;= 0x0500)
End Type

Private Const OFN_READONLY = &amp;amp;H1
Private Const OFN_OVERWRITEPROMPT = &amp;amp;H2
Private Const OFN_HIDEREADONLY = &amp;amp;H4
Private Const OFN_NOCHANGEDIR = &amp;amp;H8
Private Const OFN_SHOWHELP = &amp;amp;H10
Private Const OFN_ENABLEHOOK = &amp;amp;H20
Private Const OFN_ENABLETEMPLATE = &amp;amp;H40
Private Const OFN_ENABLETEMPLATEHANDLE = &amp;amp;H80
Private Const OFN_NOVALIDATE = &amp;amp;H100
Private Const OFN_ALLOWMULTISELECT = &amp;amp;H200
Private Const OFN_EXTENSIONDIFFERENT = &amp;amp;H400
Private Const OFN_PATHMUSTEXIST = &amp;amp;H800
Private Const OFN_FILEMUSTEXIST = &amp;amp;H1000
Private Const OFN_CREATEPROMPT = &amp;amp;H2000
Private Const OFN_SHAREAWARE = &amp;amp;H4000
Private Const OFN_NOREADONLYRETURN = &amp;amp;H8000&amp;amp;
Private Const OFN_NOTESTFILECREATE = &amp;amp;H10000
Private Const OFN_NONETWORKBUTTON = &amp;amp;H20000
Private Const OFN_NOLONGNAMES = &amp;amp;H40000          &#39;  force no long names for 4.x modules
Private Const OFN_EXPLORER = &amp;amp;H80000             &#39;  new look commdlg
Private Const OFN_NODEREFERENCELINKS = &amp;amp;H100000
Private Const OFN_LONGNAMES = &amp;amp;H200000           &#39;  force long names for 3.x modules

Private Const OFN_SHAREFALLTHROUGH = 2
Private Const OFN_SHARENOWARN = 1
Private Const OFN_SHAREWARN = 0

Private Const CDERR_DIALOGFAILURE = &amp;amp;HFFFF&amp;amp;

Private Const CDERR_GENERALCODES = &amp;amp;H0
Private Const CDERR_STRUCTSIZE = &amp;amp;H1
Private Const CDERR_INITIALIZATION = &amp;amp;H2
Private Const CDERR_NOTEMPLATE = &amp;amp;H3
Private Const CDERR_NOHINSTANCE = &amp;amp;H4
Private Const CDERR_LOADSTRFAILURE = &amp;amp;H5
Private Const CDERR_FINDRESFAILURE = &amp;amp;H6
Private Const CDERR_LOADRESFAILURE = &amp;amp;H7
Private Const CDERR_LOCKRESFAILURE = &amp;amp;H8
Private Const CDERR_MEMALLOCFAILURE = &amp;amp;H9
Private Const CDERR_MEMLOCKFAILURE = &amp;amp;HA
Private Const CDERR_NOHOOK = &amp;amp;HB
Private Const CDERR_REGISTERMSGFAIL = &amp;amp;HC

Private Function GetFileName() As String
    Dim lngResult As Long
    Const MAX_BUFFER As Long = 250

    Dim OFN As OPENFILENAME

    With OFN
        .lpstrFilter = &quot;All Files (*.*)&quot; &amp;amp; vbNullChar &amp;amp; &quot;*.*&quot; &amp;amp; vbNullChar
        .nFilterIndex = 1
        .lpstrFile = Space$(MAX_BUFFER - 1) &amp;amp; vbNullChar
        .nMaxFile = Len(.lpstrFile)
        .lpstrFileTitle = Space$(MAX_BUFFER - 1) &amp;amp; vbNullChar
        .nMaxFileTitle = Len(.lpstrFileTitle)
        .lpstrInitialDir = &quot;C:\&quot;
        .flags = OFN_FILEMUSTEXIST Or OFN_PATHMUSTEXIST
        .lStructSize = LenB(OFN)
    End With

    lngResult = GetOpenFileName(OFN)

    If lngResult &amp;lt;&amp;gt; 0 Then
        GetFileName = Left$(OFN.lpstrFile, InStr(1, OFN.lpstrFile, vbNullChar) - 1)
    Else
        GetFileName = vbNullString
    End If
End Function

Public Sub ChangePicture()
    Dim strFileName As String
    Dim shp As Shape
    
    &#39; Ensure a shape is selected
    If Application.ActiveWindow.Selection.Count = 0 Then
        MsgBox &quot;Please select a shape first.&quot;
        Exit Sub
    End If
    
    strFileName = GetFileName()
    If Len(strFileName) &amp;gt; 0 Then
        Set shp = Application.ActiveWindow.Selection.PrimaryItem
        Call shp.ChangePicture(strFileName)
    End If
End Sub
&lt;/code&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/5675468380512149821/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2024/07/changing-picture-in-microsoft-visio.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/5675468380512149821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/5675468380512149821'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2024/07/changing-picture-in-microsoft-visio.html' title='Changing a Picture in Microsoft Visio'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-8317770429070263397</id><published>2024-06-19T11:41:00.000-07:00</published><updated>2024-06-19T11:41:52.541-07:00</updated><title type='text'>Getting a Microsoft Publisher Style Color to Stick</title><content type='html'>&lt;p&gt;In Microsoft Publisher, If you try to set a font color in a style, it won&#39;t seem to save. If you change the color, it will look like it saved, but if you close the file, open it again, the color will have reset to black. The trick to getting it to actually save is to change both the fill color and the outline color. Follow these steps:&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Click Home &amp;gt; Styles &amp;gt; Styles&lt;/li&gt;&lt;li&gt;Right click on the style you want to change&lt;/li&gt;&lt;li&gt;Click the &quot;Text effects...&quot; button&lt;/li&gt;&lt;li&gt;Click the Text Fill &amp;amp; Outline button at the top&lt;/li&gt;&lt;li&gt;Set the Text Fill to the Solid fill option&lt;/li&gt;&lt;li&gt;Pick your color&lt;/li&gt;&lt;li&gt;Set the Text Outline to the Solid line option&lt;/li&gt;&lt;li&gt;Pick the same color&lt;/li&gt;&lt;li&gt;Click OK&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Now your color will save to the style.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/8317770429070263397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2024/06/getting-microsoft-publisher-style-color.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/8317770429070263397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/8317770429070263397'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2024/06/getting-microsoft-publisher-style-color.html' title='Getting a Microsoft Publisher Style Color to Stick'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-4766899116299349739</id><published>2024-04-22T11:56:00.000-07:00</published><updated>2024-04-22T12:03:48.012-07:00</updated><title type='text'>How to Move a Window When You Can&#39;t Click on the Title Bar</title><content type='html'>&lt;p&gt;
  This is a little tip for how to move a window when, for some reason, the title
  bar is off the top of the screen. This can happen when&amp;nbsp; you change screen
  resolutions or have a window on a second monitor that is no longer available
  and the window gets moved to the main monitor. The trick is to click
  Alt+&amp;lt;Space&amp;gt;, M, then use the arrow keys to move the window.
&lt;/p&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj658W1gn-i6q93-G_tmqgx844fhQRJns0SfIoOaZ6uUWs4OffV3Gpt-EpNourJ7hiwDC_VD2zQ_0bA8EIhueEJU_UEtOcAnLA1Z9Qpxsucuyk46PyBcW2zJ7dTSLBFE0PtCTuGYDYe6u1qfwOBfc__MC-MH2l4Vuld-xbGP8X8Fn3YLbC9j7V0euofuUw/s768/ApplicationMenu.gif&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;185&quot; data-original-width=&quot;768&quot; height=&quot;96&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj658W1gn-i6q93-G_tmqgx844fhQRJns0SfIoOaZ6uUWs4OffV3Gpt-EpNourJ7hiwDC_VD2zQ_0bA8EIhueEJU_UEtOcAnLA1Z9Qpxsucuyk46PyBcW2zJ7dTSLBFE0PtCTuGYDYe6u1qfwOBfc__MC-MH2l4Vuld-xbGP8X8Fn3YLbC9j7V0euofuUw/w400-h96/ApplicationMenu.gif&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;
  If you went back many years ago, the application menu icon in the upper left
  of the window used to look like a minus sign. It now shows the application
  icon. Except that wasn&#39;t a minus sign, it was a picture of the space bar on
  the keyboard. Nobody, not even the programmers at Microsoft, got the reference
  that Alt+&amp;lt;Space&amp;gt; activates the application menu. M is the access key for
  Move. Once Move is activated, the arrow keys become active to move the window.
&lt;/p&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/4766899116299349739/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2024/04/how-to-move-window-when-you-cant-click.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/4766899116299349739'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/4766899116299349739'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2024/04/how-to-move-window-when-you-cant-click.html' title='How to Move a Window When You Can&#39;t Click on the Title Bar'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj658W1gn-i6q93-G_tmqgx844fhQRJns0SfIoOaZ6uUWs4OffV3Gpt-EpNourJ7hiwDC_VD2zQ_0bA8EIhueEJU_UEtOcAnLA1Z9Qpxsucuyk46PyBcW2zJ7dTSLBFE0PtCTuGYDYe6u1qfwOBfc__MC-MH2l4Vuld-xbGP8X8Fn3YLbC9j7V0euofuUw/s72-w400-h96-c/ApplicationMenu.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-2991559969657259003</id><published>2024-02-09T20:19:00.000-08:00</published><updated>2024-02-09T20:19:01.484-08:00</updated><title type='text'>Where Does Office Store the Most Recently Used List?</title><content type='html'>&lt;p&gt;Where does Microsoft Office save the Most Recently Used list for Word, Excel, etc.? The answer is in a file under this directory:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;C:\Users\&lt;i&gt;UserName&lt;/i&gt;\AppData\Local\Microsoft\Office\&lt;i&gt;VersionNumber&lt;/i&gt;\MruServiceCache&lt;/p&gt;&lt;p&gt;There will be a directory under that that is randomly generated, then under that is the product name. Then under that is a file with the name Documents_en-US (or whatever the language). That file is a JSON file that has the list in it.&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/2991559969657259003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2024/02/where-does-office-store-most-recently.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/2991559969657259003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/2991559969657259003'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2024/02/where-does-office-store-most-recently.html' title='Where Does Office Store the Most Recently Used List?'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-6404323186478568700</id><published>2022-11-07T14:29:00.000-08:00</published><updated>2022-11-07T14:29:03.875-08:00</updated><title type='text'>The Correct Way to Handle Multiple Exceptions in C#</title><content type='html'>&lt;p&gt;
  This is just a quick article on the correct way to handle multiple exceptions
  with the same code in C#. In older versions of C#, one way to handle multiple
  exceptions was code like this:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
    try
    {
        // Code that can fail
    }
    catch (IOException)
    {
       // Failure code A
    }
    catch (ArgumentException)
    {
       // Failure code A
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  This violates this violates the DRY (Don&#39;t Repeat Yourself), concept with &lt;i&gt;Failure code A&lt;/i&gt; being repeated. Yes, you can call a method (or even a lamda
  function) from the failure code, but that creates code that is elsewhere for
  something that should be handled here. Another attempt would be something like
  this:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
    try
    {
        // Code that can fail
    }
    catch (Exception ex)
    {
        if (ex is IOException || ex is ArgumentException)
        {
            // Failure code A
        }
        else
        {
            throw;
        }
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  This is better (and the right way in C# before version 6), but it is clumsy.
  Incidentally, in this code, it would be important to use just &lt;i&gt;throw&lt;/i&gt;,
  not &lt;i&gt;throw ex&lt;/i&gt; as C# does not treat them the same. Using just
  &lt;i&gt;throw&lt;/i&gt; preserves the stack trace so that the call stack shows the
  origination of the exception, whereas &lt;i&gt;throw ex&lt;/i&gt; shows the exception
  originating in this code.
&lt;/p&gt;
&lt;p&gt;Here is the right way to handle it with current versions of C#:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
    try
    {
        // Code that can fail
    }
    catch (Exception ex) when (ex is IOException or ArgumentException)
    {
        // Failure code A
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Incidentally, the convention in C# is to use &quot;ex&quot; as the variable for exceptions, as &quot;e&quot; is
  used for the second argument in event handlers, and if you have exception
  handling code in an event handler, you don&#39;t want them to conflict.&lt;br /&gt;
&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/6404323186478568700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2022/11/the-correct-way-to-handle-multiple.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/6404323186478568700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/6404323186478568700'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2022/11/the-correct-way-to-handle-multiple.html' title='The Correct Way to Handle Multiple Exceptions in C#'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-6931786999232508082</id><published>2021-11-10T10:10:00.003-08:00</published><updated>2021-11-23T12:01:13.714-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Excel"/><category scheme="http://www.blogger.com/atom/ns#" term="Excel API"/><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript"/><category scheme="http://www.blogger.com/atom/ns#" term="TypeScript"/><title type='text'>Excel Bug Changes Color on Cell Not in Range</title><content type='html'>&lt;p&gt;
  I&#39;m in the process of writing an
  &lt;a href=&quot;https://docs.microsoft.com/en-us/office/dev/add-ins/&quot;&gt;Excel add-in&lt;/a
  &gt;, using the relatively new mechanism of writing a TypeScript library. I had
  previously written this Excel add-in in C# on .NET Framework 4.8, but this
  mechanism doesn&#39;t work in .NET 5 or 6 for architectural reasons. (With a bunch
  of tricks, I got Excel calling .NET 5 code configured as a COM DLL, but it
  won&#39;t work if the user&#39;s machine is configured in some ways and I couldn&#39;t get
  the add-in recognized correctly.) The TypeScript actually calls a web API that
  then calls the C# on the server side, so this wasn&#39;t a rewrite from the ground
  up but a layer thrown on top of my previous code, but Excel never sees that.
  From Microsoft&#39;s perspective using JavaScript has the advantage that it is
  portable, meaning that these add-ins can work on Windows, iOS, the web,
  phones, or anywhere else that Microsoft can place Excel.
&lt;/p&gt;

&lt;p&gt;
  &lt;a href=&quot;https://www.typescriptlang.org/&quot;&gt;TypeScript&lt;/a&gt; is a language that
  adds strongly typed features to JavaScript. It compiles into JavaScript, so it
  works anywhere that JavaScript does. I dislike weakly typed languages like
  JavaScript, so TypeScript makes JavaScript acceptable.
&lt;/p&gt;

&lt;p&gt;
  So in the process of writing my add-in, I ran into a bug in the Excel
  Javascript/Typescripts APIs. I formatted cells A6:A11 to have a blue
  background, and oddly enough, cell A13 turned blue as well. I don&#39;t know what
  the internals of the Javascript API or Excel look like, but this bug is really
  strange, as it seems to be dependent on the data that is in a formatted cell.
  In any case, I reduced the code to a small easily reproducible case, wrote it
  up, and
  &lt;a
    href=&quot;https://github.com/OfficeDev/office-js/issues/2237#issuecomment-964841898&quot;
    &gt;submitted it to Microsoft&lt;/a
  &gt;. They confirmed the bug the same day I submitted it and have assigned it to
  a developer.
&lt;/p&gt;
&lt;p&gt;
  More info: It turns out that this is not a Javscript API bug. It is a design
  flaw in Excel. If you format the backcolor of three or more cells (doesn&#39;t
  happen with two), say A6:A8, then change a cell within three cells, say A11,
  it will also change color. This came back as BY DESIGN. What a stupid design.
  It is unfathomable to me that this is what a user would want or expect.
&lt;/p&gt;
&lt;p&gt;
  Here is some equivalent VBA code (press Alt+F11, double-click on Sheet1,
  insert the code, press F5 to run it):
  &lt;code&gt;
    &lt;pre&gt;
  Public Sub ExcelBug()
    Sheet1.Range(&quot;A1:A3&quot;).Interior.Color = vbBlue
    Sheet1.Range(&quot;A1&quot;).Value = &quot;a&quot;
    Sheet1.Range(&quot;A2&quot;).Value = &quot;b&quot;
    Sheet1.Range(&quot;A3&quot;).Value = &quot;c&quot;
  End Sub
  &lt;/pre
    &gt;
  &lt;/code&gt;
  Run the code. Now type anything into cell A5 and press enter. What do you
  think...should the backcolor change to be blue? Well, it does. Now delete the
  value and change the backcolor to be no fill. Add the following line just
  before the End Sub:
  &lt;code&gt;
    &lt;pre&gt;
      Sheet1.Range(&quot;A5&quot;).Value = &quot;d&quot;
  &lt;/pre
    &gt;
  &lt;/code&gt;
  Now run the code. A5 doesn&#39;t change to be blue. Now delete the value and type
  it again. No blue. What are the rules on when it will change to be blue? Now
  put the same data into
  &lt;a href=&quot;https://www.office.com/launch/excel?ui=en-US&amp;amp;rs=US&amp;amp;auth=1&quot;
    &gt;Excel on the web&lt;/a
  &gt;. Will it be blue or not? Answer: not. Regardless of whether they claim it is
  by design, this is a bug.
&lt;/p&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/6931786999232508082/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2021/11/excel-bug-changes-color-on-cell-not-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/6931786999232508082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/6931786999232508082'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2021/11/excel-bug-changes-color-on-cell-not-in.html' title='Excel Bug Changes Color on Cell Not in Range'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-1436765000681525497</id><published>2021-11-01T12:00:00.000-07:00</published><updated>2021-11-01T15:41:19.524-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft Access"/><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft Office"/><title type='text'>Microsoft Access Combo Box Search While Typing</title><content type='html'>&lt;p&gt;If you start typing in a Microsoft Access combo box, it might not search as you type. I eventually figured out the trick to making the search work. The problem occurs when the combo box is based on a query. For the query to work, it must be a DISTINCT query. In other words, if you go to SQL View (select View SQL from the ribbon), and the query is:&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;
SELECT tblCategory.pcCategoryId, tblCategory.strCategory
FROM tblCategory
ORDER BY tblCategory.strCategory;
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;Change it to:&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;
SELECT DISTINCT tblCategory.pcCategoryId, tblCategory.strCategory
FROM tblCategory
ORDER BY tblCategory.strCategory;
&lt;/pre&gt;&lt;/code&gt;
After that the search while typing should work.</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/1436765000681525497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2021/11/microsoft-access-combo-box-search-while.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/1436765000681525497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/1436765000681525497'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2021/11/microsoft-access-combo-box-search-while.html' title='Microsoft Access Combo Box Search While Typing'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-6734133964570553876</id><published>2021-05-13T23:13:00.001-07:00</published><updated>2021-05-13T23:13:59.583-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft Access"/><category scheme="http://www.blogger.com/atom/ns#" term="VBA"/><title type='text'>Displaying an Image in a Microsoft Access Image Control</title><content type='html'>&lt;p&gt;If you have a column in a Microsoft Access table that has the name of an image that refers to a file on the disk, you can update an image control in either a form or report with the code below. Put this code into a standard VBA module that you create with Insert Module from the menu. This code assumes that all the images are in a subdirectory of the location of the database called &quot;images&quot; if there are relative paths to the image file.&lt;/p&gt;
&lt;pre&gt;Public Const strImageFolder = &quot;images&quot;

Public Sub DisplayImage(ctlImageControl As Control, strImagePath As Variant)
    On Error GoTo ErrorHandler
    
    If IsNull(strImagePath) Then
        ctlImageControl.Visible = False
    Else
        If InStr(1, strImagePath, &quot;\&quot;) = 0 Then
            strImagePath = Application.CurrentProject.Path &amp;amp; &quot;\&quot; &amp;amp; strImageFolder &amp;amp; &quot;\&quot; &amp;amp; strImagePath
        End If
        ctlImageControl.Visible = True
        ctlImageControl.Picture = strImagePath
    End If
    Exit Sub
ErrorHandler:
    Select Case Err.Number
        Case 2114 &#39;Doesn&#39;t support the format of the file
            ctlImageControl.Visible = False
        Case 2220 &#39; Can&#39;t find the picture.
            ctlImageControl.Visible = False
        Case Else  &#39; Some other error.
            MsgBox &quot;Unexpected Error #&quot; &amp;amp; Err.Number &amp;amp; &quot; &quot; &amp;amp; Err.Description, vbExclamation, &quot;Unexpected Error&quot;
    End Select
End Sub
&lt;/pre&gt;
&lt;p&gt;To use this code in a form, if the control that contains the image name txtPicture and the image control is named imgPicture then add this code to the module for the form:&lt;/p&gt;
&lt;pre&gt;Private Sub Form_AfterUpdate()
    Call DisplayImage(Me!imgPicture, Me!txtPicture)
End Sub

Private Sub Form_Current()
    Call DisplayImage(Me!imgPicture, Me!txtPicture)
End Sub

Private Sub txtPicture_AfterUpdate()
    Call DisplayImage(Me!imgPicture, Me!txtPicture)
End Sub
&lt;/pre&gt;
&lt;p&gt;To use it in a report, assuming there is a column in the table or query the report is based on called strPicture and an image control named imgPicture, add this code to the report:&lt;/p&gt;
&lt;pre&gt;Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    Call DisplayImage(Me!imgPicture, Me!strPicture)
End Sub
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/6734133964570553876/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2021/05/displaying-image-in-microsoft-access.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/6734133964570553876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/6734133964570553876'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2021/05/displaying-image-in-microsoft-access.html' title='Displaying an Image in a Microsoft Access Image Control'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-2444879116132580967</id><published>2021-05-13T07:13:00.003-07:00</published><updated>2021-05-13T07:36:45.367-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft Office"/><category scheme="http://www.blogger.com/atom/ns#" term="VBA"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Basic for Applications"/><title type='text'>Open a URL using VBA</title><content type='html'>&lt;p&gt;This is just a quick tip on opening a hyperlink using the default browser in VBA. It uses the ShellExecute Windows API call. Call the OpenHyperlink function shown below with the URL that you want to open.
&lt;pre&gt;
Private Declare PtrSafe Function ShellExecute Lib &quot;shell32.dll&quot; Alias &quot;ShellExecuteA&quot; ( _
  ByVal hWnd As Long, _
  ByVal lpOperation As String, _
  ByVal lpFile As String, _
  ByVal lpParameters As String, _
  ByVal lpDirectory As String, _
  ByVal nShowCmd As Long _
  ) As Long

Public Function OpenHyperlink(ByRef strHyperlink As String) As Long
    OpenHyperlink = ShellExecute(0, &quot;Open&quot;, strHyperlink, vbNullString, vbNullString, vbNormalFocus)
End Function
&lt;/pre&gt;
&lt;p&gt;An example of calling it is:&lt;/p&gt;
&lt;pre&gt;
Call OpenHyperlink(&quot;http://blog.xoc.net&quot;)
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/2444879116132580967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2021/05/open-url-using-vba.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/2444879116132580967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/2444879116132580967'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2021/05/open-url-using-vba.html' title='Open a URL using VBA'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-1778246216782326544</id><published>2021-05-09T23:27:00.007-07:00</published><updated>2021-05-13T23:14:38.495-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft Access"/><category scheme="http://www.blogger.com/atom/ns#" term="VBA"/><title type='text'>Extracting Microsoft Access OLE Object Field Items</title><content type='html'>&lt;p&gt;I created a Microsoft Access database for a small set of data (&amp;lt;1000 rows). Access was a perfect database for this particular problem, allowing easy input and good reporting, and the Access accdb database format allows easy installation on different computer that have Access. However, I made a mistake in storing bitmaps in an OLE object column. Access still has a limit of two gigabytes for its native database format. Bitmaps don&#39;t compress and quickly consume all of that limit. I had entered several hundred items before running into that limit. The two gigabyte limit was reasonable in the 1990s when a 1 gigabyte drive cost over $1000 (I have a receipt!), but is ridiculously small by today&#39;s standard.&lt;/p&gt;&lt;p&gt;The VBA code below works on the table tblExample. It extracts the bitmap from an OLE Object column (olePicture) and writes it to a file on the disk. It then updates another column (strPicture) with the name of the file it wrote. The filename is constructed by the name of the primary key field (ID) followed by .bmp, thus ID of 1 becomes 1.bmp in the same directory as the database.&lt;/p&gt;&lt;p&gt;An OLE Object field has a Package Header, an OLE header, the actual data of the bitmap, some optional other stuff, and an OLE footer. The problem is that the headers are variable length with sizes embedded into them, so the actual bitmap has to be located within the data before it can be extracted. So this code extracts the sizes and skips to the appropriate place and extracts the data. It uses a helper function that constructs a long from the first four bytes of an array of bytes (although it will break if a size is over 2^31 as it would try to convert an unsigned count to a signed count, which should never happen here).&lt;/p&gt;&lt;p&gt;After running this code successfully (use the Windows File Explorer to view the bitmaps), the OLE Object column can be deleted. Other VBA code will be necessary to display the picture in the external file, which is beyond the scope of what I want to show here. The code is not very fast as it writes the file one byte at a time, but it should be a one-time thing, at least for my purpose. It also probably has some boundary conditions related to some kinds of OLE objects that break it under some conditions, but it worked for what I needed.&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;Option Compare Database
Option Explicit

Public Sub ExtractImages()
    &#39; Need a reference to the Microsoft ActiveX Data Objects 6.1 Library
    Dim rst As ADODB.Recordset
    Dim varByte As Variant
    Dim i As Long
    Dim lngLength As Long
    Dim byteVal As Byte
    Dim strFileName As String
    Dim strFilePath As String
    
    Set rst = New ADODB.Recordset
    rst.Open &quot;tblExample&quot;, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
    Do While Not rst.EOF
        If Not IsNull(rst.Fields.Item(&quot;olePicture&quot;).Value) Then
            &#39; Create the filename from the primary key ID field.
            strFileName = rst.Fields.Item(&quot;ID&quot;).Value &amp;amp; &quot;.bmp&quot;
            
            &#39; Fill strPicture with the filename
            rst.Fields.Item(&quot;strPicture&quot;).Value = strFileName
            rst.Update
            
            strFilePath = Application.CurrentProject.Path &amp;amp; &quot;\&quot; &amp;amp; strFileName
            If Dir(strFilePath) = &quot;&quot; Then
                &#39; Read the package header the package header, the second byte is the size
                varByte = rst.Fields.Item(&quot;olePicture&quot;).GetChunk(3)
                
                &#39;Extract the offset to the start of the OLE header
                varByte = rst.Fields.Item(&quot;olePicture&quot;).GetChunk(varByte(2) + 5)
                
                &#39;Get the first four bytes which holds the OLE size
                varByte = rst.Fields.Item(&quot;olePicture&quot;).GetChunk(4)
                
                &#39; Use to size to of the header to move to the end of the header
                varByte = rst.Fields.Item(&quot;olePicture&quot;).GetChunk(GetLong(varByte))
                
                &#39; Skip the next eight bytes
                varByte = rst.Fields.Item(&quot;olePicture&quot;).GetChunk(8)
                
                &#39; The next four bytes retrieves the size of the Bitmap
                varByte = rst.Fields.Item(&quot;olePicture&quot;).GetChunk(4)
                
                &#39; Turn those bytes into a length
                lngLength = GetLong(varByte)
                
                &#39; Get the bitmap
                varByte = rst.Fields.Item(&quot;olePicture&quot;).GetChunk(lngLength)
                
                &#39; Write the bitmap to the file
                Open strFilePath For Binary As #1
                For i = 0 To lngLength - 1
                    byteVal = varByte(i)
                    Put #1, , byteVal
                Next i
                Close #1
            End If
        End If
        rst.MoveNext
    Loop
    rst.Close
    Set rst = Nothing
    MsgBox &quot;Done&quot;
End Sub

Public Function GetLong(ByRef varByte As Variant) As Long
    &#39; Convert the first four bytes of varByte into a long
    Dim i As Long
    Dim lngResult As Long
    
    For i = 3 To 0 Step -1
        lngResult = lngResult * 256 + varByte(i)
    Next i
    GetLong = lngResult
End Function
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/1778246216782326544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2021/05/extracting-microsoft-access-ole-object.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/1778246216782326544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/1778246216782326544'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2021/05/extracting-microsoft-access-ole-object.html' title='Extracting Microsoft Access OLE Object Field Items'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-7223206326471550049</id><published>2021-03-22T07:13:00.005-07:00</published><updated>2021-03-22T09:53:54.122-07:00</updated><title type='text'>What Does the &quot;Home&quot; Key Do in Microsoft Editors?</title><content type='html'>&lt;p&gt;I want to give a little anecdote on how I changed how people program. It was some time around 1990, maybe plus or minus a year. I was working on the Microsoft Access programming team at Microsoft. Actually they still hadn&#39;t settled on a name yet and eventually stole the name of a communications product Microsoft had shipped earlier and re-used it for their database, but I digress. I spent the majority of my hours in the buildings at Microsoft. My friends also worked at Microsoft, so when I wasn&#39;t working, I&#39;d frequently head over to their office and just hang out. We all worked long hours.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;One of my friends there was a programmer named Richard. Richard ostensibly worked on the database engine side of Microsoft Access, whereas I was on the user-interface side, but Richard had kind of &quot;god-level&quot; access to all of the code across Microsoft&#39;s Application Division. Anything that wasn&#39;t part of the operating system at Microsoft, he was authorized and trusted to go in and change.&lt;/p&gt;&lt;p&gt;I was sitting in Richard&#39;s office one night, and he said there had been a debate on what the &quot;Home&quot; key should do in Microsoft&#39;s editors. One camp said it should go to the beginning of the line. The other camp said it should go to the first non-whitespace character on the line, after any spaces or tabs. He asked, &quot;what do you think it should do?&quot; I said, &quot;what if the first time you pressed it, it went to the first non-whitespace character, but if you were already there, it went to the start of the line?&quot; He said, &quot;that&#39;s a good idea!&quot; And as I sat there, he went in and changed the code in Visual Studio and the Visual Basic editors. Try it, because it still does that today.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Now this was kind-of the dark ages in software development. Microsoft was just putting its first usability testing groups together, so today you&#39;d probably do some usability tests to see if that really worked for people. Or at least have a meeting about it. But I just happened to be in the right place at the right time, with the right programmer with the right access and skills. I got asked the question on what I thought it should do and everyone else gets to live with it for all time.&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/7223206326471550049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2021/03/what-does-home-key-do-in-microsoft.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/7223206326471550049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/7223206326471550049'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2021/03/what-does-home-key-do-in-microsoft.html' title='What Does the &quot;Home&quot; Key Do in Microsoft Editors?'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-861727719059014332</id><published>2021-02-12T23:34:00.003-08:00</published><updated>2021-11-10T10:16:58.501-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft Office"/><category scheme="http://www.blogger.com/atom/ns#" term="Office 365"/><title type='text'>Calling a .NET 5 (.NET Core) COM DLL from Microsoft Office (Excel, Word, Outlook, etc.)</title><content type='html'>&lt;p&gt;
  I have finally got a .NET 5 DLL written in C# able to be called from Microsoft
  Office! This process actually works for any application to call the DLL
  through COM.This has been a bear to figure out. It is not easy, but it can be
  done. There are some mentions of the process on the web, but I have seen no
  examples. I am going to post the code on GitHub with a sample project, and the
  full description over there.
&lt;/p&gt;
&lt;p&gt;
  So before launching into the process, here is my most basic recommendation. If
  possible, for the time being don&#39;t use .NET 5 or .NET Core at all. Use the
  .NET Framework 4.x, because it does much of the work for you. For my current
  project, that wasn&#39;t possible, because a library it needed to call was only
  going to be maintained on .NET 5, as it was also being called from at .NET 5
  front end. This recommendation will likely change as the .NET core does the
  work of providing a type library in the comhost file they create in some
  future release.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;
  But here is the basic process: 1) Create a project with a class and interface.
  2) Decorate them with appropriate attributes. 3) Add the appropriate method
  and the commands to create the correct registry entries to the project. 4) Add
  the appropriate settings to project file. 5) Build the DLL. 6) Create a
  parallel IDL file that describes the interface. 7) Compile it with the MIDL
  compiler. 8) Register the DLL. 9) In office, add a reference to the DLL.
&lt;/p&gt;
&lt;p&gt;
  There are various gotchas in this process. One of the things that is tricky is
  making sure that your DLL, the comhost wrapper, and the version of Microsoft
  Office you are calling it from all have the same bitness (32 bits or 64 bits).
&lt;/p&gt;
&lt;p&gt;
  So given all that, you can find the test project with more detailed
  documentation here:
  &lt;a
    href=&quot;https://github.com/GregReddick/ComTestLibrary/tree/master/ComTestLibrary1&quot;
    &gt;https://github.com/GregReddick/ComTestLibrary/tree/master/ComTestLibrary1&lt;/a
  &gt;
&lt;/p&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/861727719059014332/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2021/02/calling-net-5-net-core-com-dll-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/861727719059014332'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/861727719059014332'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2021/02/calling-net-5-net-core-com-dll-from.html' title='Calling a .NET 5 (.NET Core) COM DLL from Microsoft Office (Excel, Word, Outlook, etc.)'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-453254550529583317</id><published>2021-01-24T14:14:00.003-08:00</published><updated>2021-01-25T11:00:45.287-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Mastermind"/><title type='text'>Solving Mastermind</title><content type='html'>&lt;p&gt;A question was posted online recently about the best strategy for winning the game of &lt;a href=&quot;https://en.wikipedia.org/wiki/Mastermind_(board_game)&quot;&gt;Mastermind&lt;/a&gt;. Mastermind is a game played between two players, a Code Maker and a Code Breaker. The Maker makes a code of colored pegs, and the Breaker has to guess the code. After each guess, the Maker gives feedback of how many of the pegs were the right color in the right place and how many are the right color in the wrong place, indicated by black and white pegs in the board. The Breaker then makes another guess.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://upload.wikimedia.org/wikipedia/commons/2/2d/Mastermind.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;637&quot; data-original-width=&quot;600&quot; height=&quot;197&quot; src=&quot;https://upload.wikimedia.org/wikipedia/commons/2/2d/Mastermind.jpg&quot; width=&quot;185&quot; /&gt;&lt;/a&gt;&lt;/div&gt;The parameters of the game are how many possible colors there are, how many pegs are in the code, and whether the same color is allowed to be repeated in the code, as in (4 of 6, repeats).&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Donald Knuth &lt;a href=&quot;http://www.cs.uni.edu/~wallingf/teaching/cs3530/resources/knuth-mastermind.pdf&quot;&gt;wrote a paper&lt;/a&gt; on optimal play for the Breaker and showed that in four pegs in the code of six possible colors with repeats, it can be solved in no more than five tries. Donald Knuth is a deity of Computer Science, having written &lt;i&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/The_Art_of_Computer_Programming&quot;&gt;The Art of Computer Programming&lt;/a&gt;&lt;/i&gt;. I wrote a program to implement Knuth&#39;s algorithm in C#. It also creates a table at the end of how to make perfect play.&lt;/p&gt;&lt;p&gt;In my program, I replace colors with numerals since the colors are arbitrary. I have &lt;a href=&quot;https://github.com/GregReddick/Mastermind&quot;&gt;placed the code on GitHub&lt;/a&gt;. You can try the suggested algorithm on &lt;a href=&quot;https://www.onlinespiele-sammlung.de/mastermind/mastermindgames/madglibs/index.html&quot;&gt;this site&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;The program uses a &lt;a href=&quot;https://en.wikipedia.org/wiki/Minimax&quot;&gt;MinMax algorithm&lt;/a&gt;, which finds the code that will reduce the number of possible remaining codes on each play. Because of the way it works, sometimes it will make a code that might not actually solve it on the next play, but instead guarantee that it solves it in the least number of tries. There are some other algorithms that will solve it in a smaller average number of tries, but possibly having a larger maximum.&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/453254550529583317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2021/01/solving-mastermind.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/453254550529583317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/453254550529583317'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2021/01/solving-mastermind.html' title='Solving Mastermind'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-3706762770962169641</id><published>2020-06-17T12:35:00.001-07:00</published><updated>2020-06-17T12:49:32.010-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PowerPoint"/><category scheme="http://www.blogger.com/atom/ns#" term="VBA"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Basic for Applications"/><title type='text'>Creating a Break Timer in PowerPoint using VBA</title><content type='html'>&lt;div&gt;When I teach live classes, I use the &lt;a href=&quot;https://docs.microsoft.com/en-us/sysinternals/downloads/zoomit&quot;&gt;SysInternals Zoomit&lt;/a&gt; application, which has a break timer built in. However, I was teaching a online class, and Zoomit did not seem to get along with WebEx. I decided to write a break timer directly into the PowerPoint slides I was using.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The first step is to create a slide at the end of the presentation that looks like this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEGfr6DLAYL0bivLCkwn133PoqrnSWOkOjtCMgkDSm1D0V-OdAcxlu47rLymcvcpKhyFLhFCgfbZPQjzC3ZL_mkheYYH3_RsI1qI2RmRzb7QSFm92_akk_bTZeyYqGkRGI0-tZ_O_29kg/s3851/PowerPoint1.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;2136&quot; data-original-width=&quot;3851&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEGfr6DLAYL0bivLCkwn133PoqrnSWOkOjtCMgkDSm1D0V-OdAcxlu47rLymcvcpKhyFLhFCgfbZPQjzC3ZL_mkheYYH3_RsI1qI2RmRzb7QSFm92_akk_bTZeyYqGkRGI0-tZ_O_29kg/s320/PowerPoint1.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In other words, it is a standard slide with a title at the top and bullet points section below. I centered both and removed the bullet, so it just had text on the time. The code below counts on this slide as being the last in the presentation.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Next I brought up the PowerPoint Visual Basic Editor. You can do this with Alt+F11. Insert a module with Insert &amp;gt; Module from the menu. In the module, add this VBA code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Option Explicit&lt;br /&gt;&lt;br /&gt;Private Declare PtrSafe Sub Sleep Lib &quot;kernel32&quot; (ByVal Milliseconds As Long)&lt;br /&gt;Private lngPreviousSlide As Long&lt;br /&gt;Private boolEndBreak As Boolean&lt;br /&gt;&lt;br /&gt;Public Sub BreakTimer()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim dtmStart As Date&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim dtmEnd As Date&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim slidesCollection As slides&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim slideBreak As slide&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim lngCurrentSlide As Long&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dtmStart = Now&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dtmEnd = DateAdd(&quot;n&quot;, 10, dtmStart)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set slidesCollection = Application.ActivePresentation.slides&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set slideBreak = slidesCollection(slidesCollection.Count)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lngCurrentSlide = SlideShowWindows(1).View.slide.SlideIndex&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If lngCurrentSlide = slidesCollection.Count Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;On the break slide, end the break early&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boolEndBreak = True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39; Go on break&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lngPreviousSlide = lngCurrentSlide&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boolEndBreak = False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SlideShowWindows(1).View.GotoSlide slidesCollection.Count, msoTrue&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DoEvents&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do Until (Now &amp;gt; dtmEnd) Or boolEndBreak&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; slideBreak.Shapes(2).TextFrame.TextRange.Text = Format(dtmEnd - Now, &quot;n:ss&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sleep 900&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DoEvents&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SlideShowWindows(1).View.GotoSlide lngPreviousSlide, msoFalse&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;End Sub&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When this code run, it remembers the current slide, changes the code to the last slide, and starts a 10 minute countdown (Change the 10 in the DateAdd function to another number to do a different number of minutes in your break).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I then went to the master slide (View &amp;gt; Slide Master) and added a small button in the lower right hand corner. To add a button, you need to have the Developer ribbon turned on. Use File &amp;gt; Options &amp;gt; Customize Ribbon and check the checkbox next to Developer in the dialog and press OK. Then switch to your Developer ribbon.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;On the Developer ribbon, Click the Command Button icon, then draw the button on the master slide. Then click the Properties button on the ribbon. Set the name of the button to cmdBreak, and select a clock type image file in the Picture property by hitting the ... button on the right. Then double-click on the button you just created. This creates an Event Handler for the button. In the Event Handler, add this code:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Option Explicit&lt;br /&gt;&lt;br /&gt;Private Sub cmdBreak_Click()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call BreakTimer&lt;br /&gt;End Sub&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Close the Master slide. Run your presentation. Whenever you want to call a break, click the button in the lower right of the current slide. It will jump to your break slide and start counting down. At the end of the break, it will jump back to the slide it was on. If you want to end the break early, on the break slide, click the break button and it will end it (the code is re-entrant, so it can be processing and the button is hit again, which executes it a second time while the first instance is still running).&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/3706762770962169641/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2020/06/creating-break-timer-in-powerpoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/3706762770962169641'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/3706762770962169641'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2020/06/creating-break-timer-in-powerpoint.html' title='Creating a Break Timer in PowerPoint using VBA'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEGfr6DLAYL0bivLCkwn133PoqrnSWOkOjtCMgkDSm1D0V-OdAcxlu47rLymcvcpKhyFLhFCgfbZPQjzC3ZL_mkheYYH3_RsI1qI2RmRzb7QSFm92_akk_bTZeyYqGkRGI0-tZ_O_29kg/s72-c/PowerPoint1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-7230869420664238489</id><published>2019-05-01T10:40:00.000-07:00</published><updated>2019-05-01T10:40:12.425-07:00</updated><title type='text'>Visual Studio 2019 Community has CodeLens</title><content type='html'>I have been asking for many years in this blog that Visual Studio get CodeLens on the cheaper versions.of Visual Studio. CodeLens shows the number of references to piece of code immediately below the method first line, and quickly allows getting to those references. It is actually configurable, so it can show other information as well, but the reference count is the default.&lt;br /&gt;
&lt;br /&gt;
When Microsoft first made CodeLens available, it was only available on the $12000 version of Visual Studio. It has finally made its way into the Community Edition as of the recent release of Visual Studio 2019. The Community Edition is the version available for free for very small companies, educational, and personal use.&lt;br /&gt;
&lt;br /&gt;
Now if they would make Code Coverage available on the Community Edition, it would make me happy. Code Coverage allows seeing what code has been hit by test suites and where additional tests need to be written. There is the free AxoCover that does pretty well, but having the Microsoft version available would be better. This is my biggest missing feature in the Visual Studio that I use.</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/7230869420664238489/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2019/05/visual-studio-2019-community-has.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/7230869420664238489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/7230869420664238489'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2019/05/visual-studio-2019-community-has.html' title='Visual Studio 2019 Community has CodeLens'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-6629050975022650128</id><published>2019-01-30T23:58:00.000-08:00</published><updated>2019-02-01T13:59:55.815-08:00</updated><title type='text'>How to Delete an Excessively Long Directory on NTFS</title><content type='html'>The current version of Windows has some throwbacks to the days of the DOS operating system. Back in the day, DOS had a limit on filenames that they could not be more than 260 or so characters long (there was a little fudging between the limit on directories and filenames, but let&#39;s just call it 260).&lt;br /&gt;
&lt;br /&gt;
The current NTFS file system doesn&#39;t have that 260 character limit. However, many of the tools that talk to NTFS, like the Windows Explorer and the command line still do have the limit. So if you have a tool that doesn&#39;t have the limit, it can create a directory that you cannot delete from the Windows Explorer or the command line. Arg!&lt;br /&gt;
&lt;br /&gt;
The solution is to make the entire directory path shorter than 260 characters, then you can delete the directory. Go to Windows explorer, and drill down into your excessively long directory path until you cannot go any deeper. Then drag that deepest directory you can reach and move it to be a subdirectory of the root (or somewhere much further up the directory tree if the name conflicts). Delete the directory path that you dragged from, which should now be short enough to delete. Then drill down in your new path from the root...you should be able to reach further down than you could before because the limit only applies from the root. Repeat again and again until you can get to the bottom of the tree.&lt;br /&gt;
&lt;br /&gt;
As an additional note: The most common reason for the long directory name problem is that Windows has a bug where it creates a recursive reparsepoint for a directory called &quot;Application Data&quot;. This puts the directory as a subdirectory of itself. This means that you can into this subdirectory forever. So if you use a tool like robocopy to copy the directory tree, it will drill down until it hits the NTFS limit on the directory name (much longer than 260) and keep copying the directory. Then you can&#39;t delete the directory it copied. To remove a reparsepoint, you can do the following commands from a command prompt:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;cd &quot;\users\myacct\appdata\local\application data&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace;&quot;&gt;fsutil reparsepoint delete &quot;application data&quot;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/6629050975022650128/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2019/01/how-to-delete-excessively-long.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/6629050975022650128'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/6629050975022650128'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2019/01/how-to-delete-excessively-long.html' title='How to Delete an Excessively Long Directory on NTFS'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-4009179757235047577</id><published>2018-08-30T11:14:00.000-07:00</published><updated>2018-08-30T12:00:27.648-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio"/><title type='text'>Using the New Features in the Latest Versions of C#</title><content type='html'>The current version of Visual Studio 2017 (15.8.2 the day this is posted) actually supports C# version 7.3. You can see the new features by looking at the &lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/&quot; target=&quot;_blank&quot;&gt;C# feature list&lt;/a&gt;. However, by default, Visual Studio will use C# version 7.0. To use versions after 7.0, you will need to go to the project properties, select Build, then click the Advanced button. In the dialog is a setting for Language Version. Changing this to 7.3, for example, will enable the latest features.&lt;br /&gt;
&lt;br /&gt;
You can use this same setting for turning off features. If you don&#39;t like the stuff they added to C# version 7, you can go back to 6, or even back to 3. They have been pretty good, however, at not screwing up the language with features added in later versions. I can&#39;t think of a feature where I went, &quot;I wish they didn&#39;t put that in the language.&quot; I think lambda expressions are overused by a lot of people, but there are places where they are appropriate. I also use &quot;var&quot; as little as possible, but there are places where var is necessary and useful. The usage of these features is a coding style issue, not a problem with the language itself.&lt;br /&gt;
&lt;br /&gt;
You can see the features that might be coming in future versions of C# at &lt;a href=&quot;https://github.com/dotnet/roslyn/blob/master/docs/Language%20Feature%20Status.md&quot; target=&quot;_blank&quot;&gt;this page&lt;/a&gt;. The biggest feature that is being discussed is &lt;a href=&quot;https://github.com/dotnet/csharplang/blob/master/proposals/nullable-reference-types.md&quot; target=&quot;_blank&quot;&gt;non-nullable reference types&lt;/a&gt;. With these, you can specify that a specific reference type cannot ever be null. This will likely change how a lot of C# code gets written.</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/4009179757235047577/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2018/08/using-new-features-in-latest-versions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/4009179757235047577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/4009179757235047577'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2018/08/using-new-features-in-latest-versions.html' title='Using the New Features in the Latest Versions of C#'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-4698433464264836310</id><published>2018-06-10T01:01:00.000-07:00</published><updated>2018-06-10T20:12:12.268-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Caliburn.Micro"/><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML"/><title type='text'>Using UserControls with Caliburn.Micro</title><content type='html'>It is common to want to create a reusable UserControl, to be placed into a WPF (Windows Presentation Foundation) screen. This can be done one of two ways:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;ViewModel First&lt;/li&gt;
&lt;li&gt;View First&lt;/li&gt;
&lt;/ul&gt;
The techniques below will show how to do both of these schemes using Caliburn.Micro to perform the plumbing to connect them up. It took me quite a bit of research to figure out how to make these happen, particularly the View first, scheme. Both of these techniques can be used to create a UserControl in a Window that was itself generated using the other technique. For example, a window that was created using the ViewModel First scheme can include a UserControl that is created using the View First scheme.&lt;br /&gt;
&lt;br /&gt;
In the example code below, the main window View is called&amp;nbsp; MainWindowView and has a ViewModel called MainWindowViewModel. The ViewModel First control has a ViewModel called ViewModelFirstTestControlViewModel, which is displayed with the View called ViewModelFirstTestControlView. The View First control has a View called ViewFirstTestControlView and has a ViewModel called ViewFirstTestControlViewModel.&lt;br /&gt;
&lt;br /&gt;
The ViewModel first scheme places a ContentControl into the MainWindowView, with a x:Name attribute. For example:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: white; color: black; font-family: Consolas; font-size: 13;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;ContentControl&lt;/span&gt;
 &lt;span style=&quot;color: red;&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;Name&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;ViewModelFirstTestControlViewModel&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
The MainWindowViewModel then has this code:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: white; color: black; font-family: Consolas; font-size: 13;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;TestSystem.ViewModels
{
 &lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt;&amp;nbsp;Caliburn.Micro;
 
 &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;A&amp;nbsp;ViewModel&amp;nbsp;for&amp;nbsp;the&amp;nbsp;main&amp;nbsp;window.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;seealso&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;nbsp;cref&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;T:Caliburn.Micro.PropertyChangedBase&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;/&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;MainWindowViewModel&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;PropertyChangedBase&lt;/span&gt;
 {
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;Initializes&amp;nbsp;a&amp;nbsp;new&amp;nbsp;instance&amp;nbsp;of&amp;nbsp;the&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;see&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;nbsp;cref&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;MainWindowViewModel&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;class.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;MainWindowViewModel()
  {
   &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.ViewModelFirstTestControlViewModel&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;ViewModelFirstTestControlViewModel&lt;/span&gt;(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;ViewModel&amp;nbsp;First&amp;nbsp;Set&amp;nbsp;Content&quot;&lt;/span&gt;);
  }
 
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;Gets&amp;nbsp;the&amp;nbsp;ViewModelFirst&amp;nbsp;test&amp;nbsp;control&amp;nbsp;view&amp;nbsp;model.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;The&amp;nbsp;ViewModelFirst&amp;nbsp;test&amp;nbsp;control&amp;nbsp;view&amp;nbsp;model.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;ViewModelFirstTestControlViewModel&lt;/span&gt;&amp;nbsp;ViewModelFirstTestControlViewModel
  {
   &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt;;
   &lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;set&lt;/span&gt;;
  }
 }
}&lt;/pre&gt;
&lt;br /&gt;
So the constructor of the MainWindowViewModel instantiates the ViewModel of the UserControl, passing any arguments to initialize the values in the control. A property with the same name as the x:Name of the ContentControl exposes that ViewModel to the ContentControl. When the ContentControl needs to display the ViewModel, Caliburn.Micro finds the appropriate View and displays that as the content of the ContentControl.&lt;br /&gt;
&lt;br /&gt;
The content of the actual UserControl View in this example looks like this, but could be virtually anything you want:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: white; color: black; font-family: Consolas; font-size: 13;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;UserControl&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;Class&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;TestSystem.Views.ViewModelFirstTestControlView&quot;&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt; xmlns&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt; xmlns&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;StackPanel&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;TextBlock&lt;/span&gt;
  &lt;span style=&quot;color: red;&quot;&gt; Text&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;{&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;Binding&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;Path&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Caption&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;/&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;StackPanel&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;UserControl&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
The ViewModel for the control in this example look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: white; color: black; font-family: Consolas; font-size: 13;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;TestSystem.ViewModels
{
 &lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt;&amp;nbsp;Caliburn.Micro;
 
 &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;A&amp;nbsp;ViewModel&amp;nbsp;for&amp;nbsp;the&amp;nbsp;ViewModelFirst&amp;nbsp;test&amp;nbsp;control.&amp;nbsp;This&amp;nbsp;class&amp;nbsp;cannot&amp;nbsp;be&amp;nbsp;inherited.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;seealso&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;nbsp;cref&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;T:Caliburn.Micro.PropertyChangedBase&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;/&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;sealed&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;ViewModelFirstTestControlViewModel&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;PropertyChangedBase&lt;/span&gt;
 {
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;The&amp;nbsp;caption.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;&amp;nbsp;caption&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Default&amp;nbsp;ViewModel&amp;nbsp;first&amp;nbsp;caption&quot;&lt;/span&gt;;
 
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;Initializes&amp;nbsp;a&amp;nbsp;new&amp;nbsp;instance&amp;nbsp;of&amp;nbsp;the&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;see&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;nbsp;cref&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ViewModelFirstTestControlViewModel&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;class.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;ViewModelFirstTestControlViewModel()
  {
  }
 
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;Initializes&amp;nbsp;a&amp;nbsp;new&amp;nbsp;instance&amp;nbsp;of&amp;nbsp;the&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;see&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;nbsp;cref&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ViewModelFirstTestControlViewModel&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;class.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;param&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;nbsp;name&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;caption&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;The&amp;nbsp;caption.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;param&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;ViewModelFirstTestControlViewModel(&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;&amp;nbsp;caption)
  {
   &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.caption&amp;nbsp;=&amp;nbsp;caption;
  }
 
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;Gets&amp;nbsp;or&amp;nbsp;sets&amp;nbsp;the&amp;nbsp;caption.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;The&amp;nbsp;caption.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;&amp;nbsp;Caption
  {
   &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt;
   {
    &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.caption;
   }
 
   &lt;span style=&quot;color: blue;&quot;&gt;set&lt;/span&gt;
   {
    &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;value&lt;/span&gt;&amp;nbsp;!=&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.caption)
    {
     &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.caption&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;value&lt;/span&gt;;
     &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.NotifyOfPropertyChange(()&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.Caption);
    }
   }
  }
 }
}&lt;/pre&gt;
&lt;br /&gt;
The main point about the code is that there is a constructor that takes any initial values to be set for the control. You may not actually need the default constructor.&lt;br /&gt;
&lt;br /&gt;
Now, let&#39;s examine how to do virtually the same thing, but do it View First. In the MainWindowView, there is this code to place the control into the View:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: white; color: black; font-family: Consolas; font-size: 13;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;ctl&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;ViewFirstTestControlView&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt; cm&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;Bind.Model&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;TestSystem.ViewModels.ViewFirstTestControlViewModel&quot;&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt; Caption&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;View&amp;nbsp;First&amp;nbsp;Set&amp;nbsp;Content&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
For this Xaml to work, two namespace must be defined:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: white; color: black; font-family: Consolas; font-size: 13;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt; xmlns&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;cm&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;http://www.caliburnproject.org&quot;&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt; xmlns&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;ctl&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;clr-namespace:TestSystem.Views&quot;&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;br /&gt;
The cm namespace comes from the Caliburn.Micro project. Many people use &quot;cal&quot; instead of &quot;cm&quot;, but I&#39;ve got a namespace for &quot;calendrics&quot; in some of&amp;nbsp; my projects, so use cm instead. The &quot;ctl&quot; namespace is where your views reside.&lt;br /&gt;
&lt;br /&gt;
The cm:Bind.Model specifies the ViewModel for the control. The Caption passes in the initial value of the control.&lt;br /&gt;
&lt;br /&gt;
This retrieves the View for the control. The View looks very similar the the ViewModel First View, with some additions:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: white; color: black; font-family: Consolas; font-size: 13;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;UserControl&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;Class&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;TestSystem.Views.ViewFirstTestControlView&quot;&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt; xmlns&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt; xmlns&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;vm&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;clr-namespace:TestSystem.ViewModels&quot;&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt; xmlns&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;UserControl.Resources&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;vm&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;ViewFirstTestControlViewModel&lt;/span&gt;
  &lt;span style=&quot;color: red;&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;Key&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;ViewFirstTestControlViewModel&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;/&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;UserControl.Resources&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;StackPanel&lt;/span&gt;
 &lt;span style=&quot;color: red;&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;Name&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;root&quot;&lt;/span&gt;
 &lt;span style=&quot;color: red;&quot;&gt; DataContext&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;{&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;StaticResource&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;ViewFirstTestControlViewModel&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;TextBlock&lt;/span&gt;
  &lt;span style=&quot;color: red;&quot;&gt; Text&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&quot;{&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;Binding&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;Path&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;Caption&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp;/&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;StackPanel&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #a31515;&quot;&gt;UserControl&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
The additions specify the ViewModel for the control as a resource and binds the DataContext of the first child control to that ViewModel. However, with View First, the thing you can&#39;t avoid is having code behind. The code behind for the UserControl looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: white; color: black; font-family: Consolas; font-size: 13;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;TestSystem.Views
{
 &lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt;&amp;nbsp;System.Windows.Controls;
 
 &lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt;&amp;nbsp;TestSystem.ViewModels;
 
 &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;A&amp;nbsp;view&amp;nbsp;first&amp;nbsp;test&amp;nbsp;control&amp;nbsp;view.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;seealso&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;nbsp;cref&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;T:System.Windows.Controls.UserControl&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;/&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;seealso&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;nbsp;cref&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;T:System.Windows.Markup.IComponentConnector&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;/&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;partial&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;ViewFirstTestControlView&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;UserControl&lt;/span&gt;
 {
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;The&amp;nbsp;view&amp;nbsp;model.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;ViewFirstTestControlViewModel&lt;/span&gt;&amp;nbsp;vm;
 
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;Initializes&amp;nbsp;a&amp;nbsp;new&amp;nbsp;instance&amp;nbsp;of&amp;nbsp;the&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;see&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;nbsp;cref&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #2b91af;&quot;&gt;ViewFirstTestControlView&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;class.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;ViewFirstTestControlView()
  {
   &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.InitializeComponent();
   &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.vm&amp;nbsp;=&amp;nbsp;(&lt;span style=&quot;color: #2b91af;&quot;&gt;ViewFirstTestControlViewModel&lt;/span&gt;)&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.root.DataContext;
  }
 
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;Gets&amp;nbsp;or&amp;nbsp;sets&amp;nbsp;the&amp;nbsp;caption.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;The&amp;nbsp;caption.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;&amp;nbsp;Caption
  {
   &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt;
   {
    &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.vm.Caption;
   }
 
   &lt;span style=&quot;color: blue;&quot;&gt;set&lt;/span&gt;
   {
    &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.vm.Caption&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;value&lt;/span&gt;;
   }
  }
 }
}&lt;/pre&gt;
&lt;br /&gt;
The code behind does the InitializeComponent(), then sets the ViewModel to the DataContext that was set in the view. This, in turn, is used to have the property of the control talk to the ViewModel. The ViewModel of the control looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background: white; color: black; font-family: Consolas; font-size: 13;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;TestSystem.ViewModels
{
 &lt;span style=&quot;color: blue;&quot;&gt;using&lt;/span&gt;&amp;nbsp;Caliburn.Micro;
 
 &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;A&amp;nbsp;ViewModel&amp;nbsp;for&amp;nbsp;the&amp;nbsp;ViewFirst&amp;nbsp;test&amp;nbsp;control.&amp;nbsp;This&amp;nbsp;class&amp;nbsp;cannot&amp;nbsp;be&amp;nbsp;inherited.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;seealso&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;nbsp;cref&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;T:Caliburn.Micro.PropertyChangedBase&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;/&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;sealed&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;ViewFirstTestControlViewModel&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #2b91af;&quot;&gt;PropertyChangedBase&lt;/span&gt;
 {
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;The&amp;nbsp;text.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;&amp;nbsp;caption&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;Default&amp;nbsp;View&amp;nbsp;first&amp;nbsp;caption&quot;&lt;/span&gt;;
 
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;Gets&amp;nbsp;or&amp;nbsp;sets&amp;nbsp;the&amp;nbsp;text.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: grey;&quot;&gt;///&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;The&amp;nbsp;text.&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: grey;&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: blue;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;string&lt;/span&gt;&amp;nbsp;Caption
  {
   &lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt;
   {
    &lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.caption;
   }
 
   &lt;span style=&quot;color: blue;&quot;&gt;set&lt;/span&gt;
   {
    &lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: blue;&quot;&gt;value&lt;/span&gt;&amp;nbsp;!=&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.caption)
    {
     &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.caption&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;value&lt;/span&gt;;
     &lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.NotifyOfPropertyChange(()&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;this&lt;/span&gt;.Caption);
    }
   }
  }
 }
}&lt;/pre&gt;
&lt;br /&gt;
This is almost the same as the ViewModel of the ViewModel First control, except it does not need the constructors, since the property is changed from the MainWindowView. (It has a default constructor that does nothing.)&lt;br /&gt;
&lt;br /&gt;
A zip file for the entire project is found &lt;a href=&quot;http://www.xoc.net/downloads/TestSystem.zip&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;. Included are all the files, including the Caliburn.Micro bootstrapper that sets up the files.&lt;br /&gt;
&lt;br /&gt;
If you know of more efficient ways of doing any of the things I&#39;ve described, please let me know in the comments.</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/4698433464264836310/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2018/06/using-usercontrols-with-caliburnmicro.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/4698433464264836310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/4698433464264836310'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2018/06/using-usercontrols-with-caliburnmicro.html' title='Using UserControls with Caliburn.Micro'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-8154346465443047941</id><published>2018-01-23T23:09:00.001-08:00</published><updated>2018-01-24T00:59:41.597-08:00</updated><title type='text'>Compiling Help File as Part of Visual Studio Solution</title><content type='html'>I think that Microsoft has dropped the ball on creating help files. The technology has not changed in about 25 years, and was never simple in the first place. The tools are primitive. Furthermore, there is no simple way to incorporate the building of the help file into a Visual Studio solution.&lt;br /&gt;
&lt;br /&gt;
Building a help file is pretty much the same as building a web site. The pages are authored in HTML. The only difference is that there are some supplemental files that tell it how to build the Table of Contents (.hhc file) and the Index (.hhk file) to the help file, as well as a file to tell it what all the all the other files and provide the settings (.hhp file). There is a compiler that compiles the web site into a single .chm file.&lt;br /&gt;
&lt;br /&gt;
To start with, let&#39;s go over the tools needed to build a help file. You need the &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/windows/desktop/ms669985(v=vs.85).aspx&quot; target=&quot;_blank&quot;&gt;Microsoft HTML Help Workshop&lt;/a&gt;. This provides the help compiler (hhc.exe), as well as a rudimentary Windows application for managing the files (hhw.exe). The content files are HTML. If you know HTML well, you can create them in any text editor. Despite knowing HTML backwards and forwards, I still prefer to edit them in an interface that understands HTML as it allows me to reformat the HTML and other features. Microsoft produced a tool for editing HTML that they have since abandoned called &lt;a href=&quot;https://www.microsoft.com/en-us/download/details.aspx?id=36179&quot; target=&quot;_blank&quot;&gt;Microsoft Expression Web&lt;/a&gt;. You can download it for free from the Microsoft web site.&lt;br /&gt;
&lt;br /&gt;
Visual Studio does not have a template that works with help file projects. So we have to kind of fake it out. Create a console application that will act as the help file project. The console application does not need to do anything, as we will be ignoring the compiled executable, and instead using the build events for the project to accomplish what we need.&lt;br /&gt;
&lt;br /&gt;
Use hhw.exe to create the help project. Add HTML files to the 
project. The stuff below assumes that the name of the .hhp file is 
HelpProject.hhp, but you can rename it to anything else by making the appropriate changes below.&amp;nbsp; The HelpProject.hhp should be added to the root of the
 help project.&lt;br /&gt;
&lt;br /&gt;
Then add compiling the help file to the build events for the console application. However, we have to work around one minor problem: the help compiler returns one on success and zero on failure, rather than the Windows standard of the other way around. Visual Studio considers a build event that returns something non-zero as a failure and terminates the build of the project. To reverse that, we need a short batch file. Add to the help project a file named helpcompiler.bat file that looks like this:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&quot;%ProgramFiles(x86)%\HTML Help Workshop\hhc.exe&quot; %1
if not errorlevel 1 exit /B 1&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Then add this to the pre-build event in the Project Properties:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
$(ProjectDir)helpcompiler.bat $(ProjectDir)HelpProject.hhp
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
When the help file compiles, it will produce HelpProject.chm in the same directory as where the HelpProject.hhp file is created. This is the compiled help file that you need. Add a line to the post-build event that copies the HelpProject.chm file to the final location where it is needed. For example:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;xcopy /Y $(ProjectDir)HelpProject.chm $(SolutionDir)SomeOtherProject\bin\$(ConfigurationName)&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
With this hack,&amp;nbsp; Visual Studio will build the help file and copy it to where it needs to go as part of the build of the Solution.</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/8154346465443047941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2018/01/compiling-help-file-as-part-of-visual.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/8154346465443047941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/8154346465443047941'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2018/01/compiling-help-file-as-part-of-visual.html' title='Compiling Help File as Part of Visual Studio Solution'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-3018915641377848603</id><published>2017-12-13T16:31:00.000-08:00</published><updated>2017-12-13T16:31:21.269-08:00</updated><title type='text'>Use .editorconfig File to Enforce Coding Conventions</title><content type='html'>As you may know, I literally wrote the book on C# coding conventions. You can get my book, &lt;a href=&quot;https://www.amazon.com/Reddick-Style-Guide-practices-writing/dp/0692531742&quot; target=&quot;_blank&quot;&gt;The Reddick C# Style Guide&lt;/a&gt; on Amazon. Since the book was published, C# and Visual Studio have changed a little, as they have added new features to both. There is nothing that I would change in the book, but a few of the new features they added to version 7.x of C# that are not mentioned, such as tuples and pattern matching. Until I can get around to updating the book, there is a nifty feature in Visual Studio 2017 that you can use to enforce what I consider to be the proper coding style for C#.&lt;br /&gt;
&lt;br /&gt;
In the root of your code, add a text file called .editorconfig. The basic format for this file is defined at &lt;a href=&quot;http://editorconfig.org/&quot;&gt;http://EditorConfig.org&lt;/a&gt;. There are specific entries that are understood in Visual Studio 2017, starting with version 15.3, that can be found at &lt;a href=&quot;https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference&quot;&gt;https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference&lt;/a&gt;. This is the file that I use, that uses the I consider to be the right style. Even if you don&#39;t agree, feel free to use it as a template for your own style.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;# http://EditorConfig.org
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference

root=true

[*]
indent_style=tab
indent_size=tab
tab_width=4
end_of_line=crlf
charset=utf-8
trim_trailing_whitespace=true
insert_final_newline=false
max_line_length=140

[*.{cs,vb}]

# &quot;This.&quot; and &quot;Me.&quot; qualifiers
dotnet_style_qualification_for_field=true:warning
dotnet_style_qualification_for_property=true:warning
dotnet_style_qualification_for_method=true:warning
dotnet_style_qualification_for_event=true:warning

# Language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members=true:warning
dotnet_style_predefined_type_for_member_access=true:warning

# Modifier preferences
dotnet_style_require_accessibility_modifiers=always:warning
csharp_preferred_modifier_order=public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:warning
visual_basic_preferred_modifier_order=Partial, Default, Private, Protected, Public, Friend, NotOverridable, Overridable, MustOverride, Overloads, Overrides, MustInherit, NotInheritable, Static, Shared, Shadows, ReadOnly, WriteOnly, Dim, Const,WithEvents, Widening, Narrowing, Custom, Async:nonewarning

# Expression-level preferences
dotnet_style_object_initializer=true:warning
dotnet_style_collection_initializer=true:warning
dotnet_style_explicit_tuple_names=true:warning
dotnet_style_coalesce_expression=true:warning
dotnet_style_null_propagation=true:warning

# Implicit and explicit types
csharp_style_var_for_built_in_types=false:warning
csharp_style_var_when_type_is_apparent=false:warningn
csharp_style_var_elsewhere=false:warning

# Expression-bodied members
csharp_style_expression_bodied_methods=false:warning
csharp_style_expression_bodied_constructors=false:warning
csharp_style_expression_bodied_operators=false:warning
csharp_style_expression_bodied_properties=false:warning
csharp_style_expression_bodied_indexers=false:warning
csharp_style_expression_bodied_accessors=false:warning

# Inlined variable declarations
csharp_style_inlined_variable_declaration=true:warning

# Pattern matching
csharp_style_pattern_matching_over_is_with_cast_check=true:warning
csharp_style_pattern_matching_over_as_with_null_check=true:warning

# Expression-level preferences
csharp_prefer_simple_default_expression=true:warning
csharp_style_deconstructed_variable_declaration=true:warning
csharp_style_pattern_local_over_anonymous_function=true:warning

# &quot;Null&quot; checking preferences
csharp_style_throw_expression=false:warning
csharp_style_conditional_delegate_call=true:warning

# Code block preferences
csharp_prefer_braces=true:warning

# Organize Usings
dotnet_sort_system_directives_first=true

# Newline Options
csharp_new_line_before_open_brace=all
csharp_new_line_before_else=true
csharp_new_line_before_catch=true
csharp_new_line_before_finally=true
csharp_new_line_before_members_in_object_initializers=true
csharp_new_line_before_members_in_anonymous_types=true
csharp_new_line_between_query_expression_clauses=true

# Indentation Options
csharp_indent_case_contents=true
csharp_indent_switch_labels=true
csharp_indent_labels=flush_left

# Spacing Options
csharp_space_after_cast=false
csharp_space_after_keywords_in_control_flow_statements=true
csharp_space_between_method_declaration_parameter_list_parentheses=false
#csharp_space_between_parentheses=

# Wrapping Options
csharp_preserve_single_line_statements=false
csharp_preserve_single_line_blocks=false&lt;/code&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/3018915641377848603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2017/12/use-editorconfig-file-to-enforce-coding.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/3018915641377848603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/3018915641377848603'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2017/12/use-editorconfig-file-to-enforce-coding.html' title='Use .editorconfig File to Enforce Coding Conventions'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-2106798667354282163</id><published>2017-11-21T10:06:00.001-08:00</published><updated>2017-11-21T10:06:46.485-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Caliburn.Micro"/><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML"/><title type='text'>WPF RibbonSplitButton Activates Twice</title><content type='html'>On a WPF (Windows Presentation Foundation) RibbonSplitButton there are two parts. There is a button at the top, and a down arrow. The down arrow causes a menu to appear. If you click one of the menu items, there is what I would consider to be a bug, but what &lt;a href=&quot;https://social.msdn.microsoft.com/Forums/vstudio/en-US/da13b5f5-5252-4332-9ec3-0b78c6395693/ribbonapplicationsplitmenuitem-triggers-command-twice?forum=wpf&quot; target=&quot;_blank&quot;&gt;Microsoft considers to be &quot;By Design&quot;&lt;/a&gt; where it triggers the event code twice. Essentially, it triggers it once for the menu item, and once for the button.&lt;br /&gt;
&lt;br /&gt;
There is a way to handle the problem. Essentially on the first trigger, you need to set the &quot;Handled&quot; property of the RoutedEventArgs to be true. The solution posted on the Microsoft site requires an event handler in code-behind, which isn&#39;t compatible with the MVVM architecture. Here is how I handled it using Caliburn.Micro for a button in my application that is supposed to start Excel in one of two different ways. The button at the top executes it with #0, and the two menu items executes it with #1 and #0.&lt;br /&gt;
&lt;br /&gt;
First, here is the XAML. The key part of this is to pass the $executionContext as an argument to the method. This gets the necessary property to where it can be modified.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&amp;lt;ribbon:RibbonSplitButton
 cal:Message.Attach=&quot;[Event Click]=[Excel(0, $executionContext)]&quot;
 IsEnabled=&quot;{Binding CanExcel}&quot;
 KeyTip=&quot;X&quot;
 Label=&quot;{x:Static loc:ShellViewResources.Excel}&quot;
 LargeImageSource=&quot;/Xoc.MayaCalendar.Windows;component/Assets/Images/Ribbon/ExcelLarge.png&quot;
 SmallImageSource=&quot;/Xoc.MayaCalendar.Windows;component/Assets/Images/Ribbon/ExcelSmall.png&quot;&amp;gt;
 &amp;lt;ribbon:RibbonMenuItem
  Header=&quot;{x:Static loc:ShellViewResources.Excel}&quot;
  ImageSource=&quot;/Xoc.MayaCalendar.Windows;component/Assets/Images/Ribbon/PrintSmall.png&quot;
  cal:Message.Attach=&quot;[Event Click]=[Excel(1, $executionContext)]&quot; /&amp;gt;
 &amp;lt;ribbon:RibbonMenuItem
  Header=&quot;{x:Static loc:ShellViewResources.ExcelExample}&quot;
  ImageSource=&quot;/Xoc.MayaCalendar.Windows;component/Assets/Images/Ribbon/PrintSmall.png&quot;
  cal:Message.Attach=&quot;[Event Click]=[Excel(0, $executionContext)]&quot; /&amp;gt;
&amp;lt;/ribbon:RibbonSplitButton&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
The next part is to handle the event. In the Caliburn.Micro code, it starts with:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
public void Excel(ContentLevel contentLevel, ActionExecutionContext executionContext)
{
 RoutedEventArgs routedEventArgs = (RoutedEventArgs)executionContext.EventArgs;
 routedEventArgs.Handled = true;
 // other code
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
This handles the event, which causes it not to cause the second event.</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/2106798667354282163/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2017/11/wpf-ribbonsplitbutton-activates-twice.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/2106798667354282163'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/2106798667354282163'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2017/11/wpf-ribbonsplitbutton-activates-twice.html' title='WPF RibbonSplitButton Activates Twice'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-7448898811987119918</id><published>2017-11-02T10:37:00.001-07:00</published><updated>2018-01-23T23:17:41.372-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Product Failure"/><category scheme="http://www.blogger.com/atom/ns#" term="Rant"/><title type='text'>Do Not Buy Avi-On Light Switches</title><content type='html'>I bought a GE Avi-On light switch for my daughter&#39;s room. This replaces the regular wall switch with one that can be remotely controlled from her phone. The idea was to allow her to turn off the overhead light from the bed. It worked for about 10 minutes until it started downloading a firmware update to the switch, at which point the update failed. The switch no longer works. Lots of people are reporting the same issue, which means there are thousands of these switches throughout the country with this problem.&lt;br /&gt;
&lt;br /&gt;
The Avi-On switches have these problems:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;The phone software always requires an internet connection and a login to the Avi-On site. Why? This is a Bluetooth app. There is no reason whatsoever that it needs a connection to a remote network. It only needs a connection between the phone and the switch.&lt;/li&gt;
&lt;li&gt;It requires location services turned on and access to the file system on the phone. Why? This just smacks of them just wanting to harvest information from the phone, because there is no need for these permissions. The only thing that would require these accesses is for a firmware update to be downloaded from the network to be pushed to the switch. Which leads to...&lt;/li&gt;
&lt;li&gt;The firmware update failed. You cannot push down a firmware update to remote switches if the firmware destroys the switch! And if your testing is abysmal and you somehow screw up and release a bad update, you must pull the firmware update off your site the moment you realize it. People have been reporting that the Avi-On current firmware update is causing problems for the last two months, but they are still pushing out the update.&lt;/li&gt;
&lt;li&gt;These switches supposedly make a Bluetooth mesh with other switches 
in the area to allow spanning past the normal range of Bluetooth. 
Bluetooth isn&#39;t the right technology for home control. The range is too short, which means you either need a huge number of these devices, or you need repeaters about every 33 feet apart. That&#39;s an expensive solution to home control. The goal on home control is to have connectivity that ends at the walls of your house, but not before.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
In summary, do not buy Avi-On GE Bluetooth light switches, or anything else made by Avi-On Labs. I will be returning this switch to where I bought it.</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/7448898811987119918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2017/11/do-not-buy-avi-on-light-switches.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/7448898811987119918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/7448898811987119918'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2017/11/do-not-buy-avi-on-light-switches.html' title='Do Not Buy Avi-On Light Switches'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5344982184119705320.post-7620578829362116801</id><published>2017-09-02T01:17:00.000-07:00</published><updated>2018-06-10T20:19:57.392-07:00</updated><title type='text'>Outlook VBA to Move Spam from Top Level Domains to Junk</title><content type='html'>There is a spammer who has been active for the last couple of months. The majority of my spam email has been coming from the top level domains .trade, .bid, .club, .stream, and .date. I get no legitimate mail from any of those top level domains.&lt;br /&gt;
&lt;br /&gt;
I wrote a VBA routine to go through my inbox and move all email from those domains to my junk folder. It appears below:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
Public Sub JunkSpamDomains()
&amp;nbsp;&amp;nbsp;&amp;nbsp; On Error GoTo ErrorHandler
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim mailItem As Outlook.mailItem
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim folderInbox As Outlook.folder
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim folderJunk As Outlook.folder
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim i As Long
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim accessor As Outlook.PropertyAccessor
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim strHeaders As String
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim lngOffset1 As Long
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim lngOffset2 As Long
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim lngDomainOffset As Long
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim strFrom As String
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim strDomain As String

&lt;/code&gt;&lt;code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Const PR_TRANSPORT_MESSAGE_HEADERS = &quot;http://schemas.microsoft.com/mapi/proptag/0x007D001E&quot;&lt;/code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Const strBanned As String = &quot;.trade|.bid|.club|.stream|.date&quot;

&amp;nbsp;&amp;nbsp;&amp;nbsp; Set folderInbox = Application.Session.GetDefaultFolder(olFolderInbox)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set folderJunk = Application.Session.GetDefaultFolder(olFolderJunk)
&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each mailItem In folderInbox.Items
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If mailItem.Class = OlObjectClass.olMail Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set accessor = mailItem.PropertyAccessor
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strHeaders = accessor.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lngOffset1 = InStr(1, strHeaders, vbCrLf &amp;amp; &quot;From: &quot;) + 8
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lngOffset2 = InStr(lngOffset1, strHeaders, &quot;&amp;gt;&quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strFrom = Mid(strHeaders, lngOffset1, lngOffset2 - lngOffset1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lngDomainOffset = InStrRev(strFrom, &quot;.&quot;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strDomain = Mid(strFrom, lngDomainOffset)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If InStr(1, strBanned, strDomain) &amp;gt; 0 Then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mailItem.Move folderJunk
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set accessor = Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set mailItem = Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If
&amp;nbsp;&amp;nbsp;&amp;nbsp; Next mailItem
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set folderInbox = Nothing
&amp;nbsp;&amp;nbsp;&amp;nbsp; Set folderJunk = Nothing
Exit Sub
ErrorHandler:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Select Case Err.Number
&amp;nbsp;&amp;nbsp;&amp;nbsp; Case Else
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox &quot;Unexpected Error #&quot; &amp;amp; Err.Number &amp;amp; &quot; &quot; &amp;amp; Err.Description
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Resume Next
&amp;nbsp;&amp;nbsp;&amp;nbsp; End Select
End Sub&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
Press Alt-F11 to open the VBA Editor. Select Insert Module from the menu to insert a new module. Paste this code into the window. You can bind a button on the Quick Access Toolbar (QAT) to this macro. Click the drop-down button on the right of the QAT, and select &quot;More Commands...&quot;. Drop the &quot;Choose Commands from:&quot; list and select &quot;Macros&quot;. Select &quot;JunkSpamDomains&quot; and click the &quot;Add&amp;gt;&amp;gt;&quot; button. Click the OK button.&lt;br /&gt;
&lt;br /&gt;
After moving message, review the Junk folder to make sure that only spam got moved.</content><link rel='replies' type='application/atom+xml' href='http://blog.xoc.net/feeds/7620578829362116801/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.xoc.net/2017/09/outlook-vba-to-move-spam-from-top-level.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/7620578829362116801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5344982184119705320/posts/default/7620578829362116801'/><link rel='alternate' type='text/html' href='http://blog.xoc.net/2017/09/outlook-vba-to-move-spam-from-top-level.html' title='Outlook VBA to Move Spam from Top Level Domains to Junk'/><author><name>Greg Reddick</name><uri>http://www.blogger.com/profile/04469566612778276012</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>