カテゴリー
SugiBlog Webエンジニアのためのお役立ちTips

ACCESS CSVデータインポート時の文字コード

TransferTextメソッドにて、テーブルにCSVデータをインポートする際、
文字コード(CodePage)を指定してインポートすることができます。

最後の引数[CodePage]を省略すると、シフトJISで読み込まれます。

DoCmd.TransferText acImportDelim, , _
    "テーブル名", "ファイルパス", True, , 932   'Shift_JIS

DoCmd.TransferText acImportDelim, , _
    "テーブル名", "ファイルパス", True, , 51932 'EUC-JP

DoCmd.TransferText acImportDelim, , _
    "テーブル名", "ファイルパス", True, , 65001 'UTF-8

DoCmd.TransferText acImportDelim, , _
    "テーブル名", "ファイルパス", True, , 50220 'JIS

CSVデータエクスポート時も同様です。

こちらに参考になる表があります。
http://www.atmarkit.co.jp/fdotnet/dotnettips/013enumenc/enumenc.html

43,264 views

フォームの入力モード制御

HTML入力フォームの入力モードを制御します。(IE5以上のみ)

設定値は以下の通りです。

auto 自動
active 入力モードON
inactive 入力モードOFF
disabled 使用不可

HTMLで直接指定する場合

<input type="text" name="item" value="" style="ime-mode: auto;">

続きを読む…»

2,533 views

PROCMAILレシピ

環境:qmail+vpopmail

迷惑メール対策
.procmailrc

基本設定

#/home/vpopmail/domains/example.jp/username/.procmailrc
#環境変数の設定
PATH=/usr/bin:/usr/local/bin
HOME=/home/vpopmail/domains/example.jp/username
MAILDIR=$HOME/Maildir
DEFAULT=$HOME/Maildir/
LOGFILE=$MAILDIR/procmail.log #省略するとログを記録しない
LOCKFILE=$MAILDIR/procmail.lock
VERBOSE=ON #詳細なログを記録する

#以下、カスタム変数
ME=username@example.jp
BLACKLIST=/home/vpopmail/domains/.blacklist #ブラックリストファイル
NGWORD=/home/vpopmail/domains/.ngword       #NGワードファイル

続きを読む…»

5,908 views

ACCESS Excelオートメーションメモ

Dim xlApp   As Object
Dim xlBook  As Object
Dim xlSheet As Object

Dim FileName   As String
Dim myFileName As String
Dim myShape    As Object

FileName = Environ("USERPROFILE") & "\デスクトップ\sample.xls"

Set xlApp   = CreateObject("Excel.Application")
Set xlBook  = xlApp.Workbooks.Add
Set xlSheet = xlBook.WorkSheets(1)

With xlSheet

    .Range("A18:D18").MergeCells = True       'セルを結合
    .Range("A18").HorizontalAlignment = -4108 '横位置を中央揃えに
    .Range("A18").Font.Size = 48              'フォントの大きさを変更

End With

'保存
xlBook.Saveas (FileName)

xlBook.Close

xlApp.Application.Quit

Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
3,291 views

Excel VBA 画像の挿入

Sub auto_open()

    Dim myFileName As String
    Dim myShape As Shape

    myFileName = ActiveWorkbook.Path & "\sample.bmp"

    ' 選択位置に画像ファイルを挿入し、変数myShapeに格納
    Set myShape = ActiveSheet.Shapes.AddPicture( _
          Filename:=myFileName, _
          LinkToFile:=False, _
          SaveWithDocument:=True, _
          Left:=Selection.Left, _
          Top:=Selection.Top, _
          Width:=0, _
          Height:=0)

    ' 挿入した画像に対して元画像と同じ高さ・幅にする
    With myShape
        .ScaleHeight 1, msoTrue
        .ScaleWidth 1, msoTrue
    End With

End Sub

ACCESSからExcelを操作し、挿入する場合
続きを読む…»

11,989 views