VBAで特殊フォルダのパスを取得する

デスクトップの取得方法

Sub Sample3()
    Dim Path As String, WSH As Variant
    Set WSH = CreateObject("WScript.Shell")
    Path = WSH.SpecialFolders("Desktop") & "\"
    ActiveWorkbook.SaveAs Path & "Sample1.xls"
    Set WSH = Nothing
End Sub

マイドキュメント

Sub Sample4()
    Dim Path As String, WSH As Variant, OpenFileName As String
    Set WSH = CreateObject("WScript.Shell")
    Path = WSH.SpecialFolders("MyDocuments") & "\"
    ChDir Path
    OpenFileName = Application.GetOpenFilename("Excelブック,*.xls")
    If OpenFileName <> "False" Then
        Workbooks.Open OpenFileName
    End If
    Set WSH = Nothing
End Sub

ネタ元

VBAで2つの画像ファイルを比較して内容が同一かどうかを判定する方法

バイナリでファイル読み込んで無理やりテキスト変換&比較する技

Function ReadBmpAsString(file_name As String) As String
    Dim bmp() As Byte
    Open file_name For Binary As #1
        ReDim bmp(LOF(1))
        Get #1, , bmp
    Close #1
    ReadBmpAsString = bmp
End Function
Sub ファイルの比較()
    Const IMAGE_FOLDER = "C:\Work\imageMSO\"
    Dim fileA As String: fileA _
        = ReadBmpAsString(IMAGE_FOLDER & "AcceptProposal.bmp")
    
    Dim fileB As String: fileB _
        = ReadBmpAsString(IMAGE_FOLDER & "AcceptInvitation.bmp")
    
    Dim fileC As String: fileC _
        = ReadBmpAsString(IMAGE_FOLDER & "AcceptAndAdvance.bmp")

    Debug.Print fileA = fileB
    Debug.Print fileA = fileC
    Debug.Print fileB = fileC
End Sub

ネタ元

wordpressログインで2段階認証なら「Google Authenticator」

1. Googleアカウントで2段階認証プロセスを有効にする
2. 手持ちのスマートフォンにGoogle認証システムのアプリをインストールし設定する
3. WordPressにGoogle Authenticatorプラグインをインストールし設定する
2段階認証を有効にするユーザーのプロフィール管理ページにアクセスすると
「Google Authenticator Settings」という項目が加わっています。
ここで設定します。
f:id:shikaku:20170514214729p:plain

ネタ元

wordpress公式テーマのフッターに表示される「proudly powered by wordpress」を変更する(消す)方法

footer.phpの

get_template_part( 'template-parts/footer/site', 'info' );

「<div class="site-info"></div>」

で囲まれた部分をコメントアウトして

&copy;Copyright <?php echo date('Y'); ?> <a href="<?php echo home_url(); ?>"><?php bloginfo( 'name' ); ?></a> All Rights Reserved.

に差し替える

ネタ元

スタイリッシュな関連ページプラグイン「Milliard」

関連ページを「スタイリッシュかも?」くらいに綺麗に表示できるツールです。

関連ページ表示時のデザイン崩れが気になる方、閲覧数を増やしたいメディアやブロガー様にお使い頂いております。

ネタ元

wordpressプラグインなしでパンくずリストを設定

functions.phpに追記

// パンくずリスト
function breadcrumb(){
    global $post;
    $str ='';
    if(!is_home()&&!is_admin()){
        $str.= '<div id="breadcrumb" class="cf"><div itemscope itemtype="http://data-vocabulary.org/Breadcrumb" style="display:table-cell;">';
        $str.= '<a href="'. home_url() .'" itemprop="url"><span itemprop="title">ホーム</span></a> &gt;&#160;</div>';
        if(is_category()) {
            $cat = get_queried_object();
            if($cat -> parent != 0){
                $ancestors = array_reverse(get_ancestors( $cat -> cat_ID, 'category' ));
                foreach($ancestors as $ancestor){
$str.='<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb" style="display:table-cell;"><a href="'. get_category_link($ancestor) .'" itemprop="url"><span itemprop="title">'. get_cat_name($ancestor) .'</span></a> &gt;&#160;</div>';
                }
            }
$str.='<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb" style="display:table-cell;"><a href="'. get_category_link($cat -> term_id). '" itemprop="url"><span itemprop="title">'. $cat-> cat_name . '</span></a> &gt;&#160;</div>';
        } elseif(is_page()){
            if($post -> post_parent != 0 ){
                $ancestors = array_reverse(get_post_ancestors( $post->ID ));
                foreach($ancestors as $ancestor){
                    $str.='<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb" style="display:table-cell;"><a href="'. get_permalink($ancestor).'" itemprop="url"><span itemprop="title">'. get_the_title($ancestor) .'</span></a> &gt;&#160;</div>';
                }
            }
        } elseif(is_single()){
            $categories = get_the_category($post->ID);
            $cat = $categories[0];
            if($cat -> parent != 0){
                $ancestors = array_reverse(get_ancestors( $cat -> cat_ID, 'category' ));
                foreach($ancestors as $ancestor){
                    $str.='<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb" style="display:table-cell;"><a href="'. get_category_link($ancestor).'" itemprop="url"><span itemprop="title">'. get_cat_name($ancestor). '</span></a>→</div>';
                }
            }
            $str.='<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb" style="display:table-cell;"><a href="'. get_category_link($cat -> term_id). '" itemprop="url"><span itemprop="title">'. $cat-> cat_name . '</span></a> &gt;&#160;</div>';
        } else{
            $str.='<div>'. wp_title('', false) .'</div>';
        }
        $str.='</div>';
    }
    echo $str;
}

表示したいところで

<?php breadcrumb(); ?>

ネタ元