msWord-テキストを2回挿入するvba入力可能フォーム
こんにちは皆さん.現在、レターヘッドテンプレートの更新に取り組んでいます.入力可能なフォームがあり、情報を入力すると、ドキュメントのブックマークにテキストが挿入されます.ただし、下のスニップでわかるように、フッターのブックマークも本文に配置されているという問題が発生しています.すべてのブックマークを削除して再挿入しました彼ら.ジョブポジションのブックマークは正常に機能していますが、このブックマークの後にケース名とケース番号も配置されています.これらもドキュメントのフッターに配置されていることがわかります.何らかの理由で、それらは複製され、JobTitletxtで配置されています.フォームのコードは以下のとおりです.
プライベートサブcmdCancel_Click()
"[キャンセル]ボタンをクリックした場合は、ドキュメントを閉じます
clearLetterHeadを呼び出す
ActiveDocument.Close(wdDoNotSaveChanges)
Letterhead.Hide
レターヘッドをアンロード
サブの終了
プライベートサブcmdOK_Click()
"[OK]ボタンをクリックしたら、ドキュメントの以下に記入します
"-名前
"-役職
"-ケース番号
"-ケース名
"-アドレス
"-Re Line
"-敬礼
"-CC
"-添付ファイル
"-宅配便
ActiveDocument.Bookmarks( "Name").Select
Selection.TypeText(txtName)
ActiveDocument.Bookmarks( "JobTitle").Select
Selection.TypeText(txtJobTitle)
ActiveDocument.Bookmarks( "CaseName").Range.Text= txtCaseName
Selection.TypeText(txtCaseName)
ActiveDocument.Bookmarks( "CaseNumber").Range.Text= txtCaseNumber
Selection.TypeText(txtCaseNumber)
ActiveDocument.Bookmarks( "Address").Select
Selection.TypeText(txtAddress)
ActiveDocument.Bookmarks( "RE").Select
Selection.TypeText(txtRe)
ActiveDocument.Bookmarks( "Salutation").Select
Selection.TypeText(txtSalutation)
ActiveDocument.Bookmarks( "CC").Select
Selection.TypeText(txtCC)
ActiveDocument.Bookmarks( "Attachments").Select
Selection.TypeText(txtAttachments)
ActiveDocument.Bookmarks( "Courier").Select
Selection.TypeText(txtCourier)
"フォームの間隔番号で設定されたドキュメント間隔を設定します
dblSpacingNumber= Val(txtSpacing)
dblSpacingNumber>10の場合
dblSpacingNumber= 10
終了する場合
dblSpacingNumber<0.1の場合
dblSpacingNumber= 0.1
終了する場合
ActiveDocument.Bookmarks( "BodyText").Select
Selection.Paragraphs.LineSpacing= LinesToPoints(dblSpacingNumber)
clearLetterHeadを呼び出す
"フォームを非表示にする
Letterhead.Hide
レターヘッドをアンロード
サブの終了
プライベートサブclearLetterHead()
txtName.Value= ""
txtJobTitle.Value= ""
txtCaseNumber.Value= ""
txtCaseName.Value= ""
txtAddress.Value= ""
txtRe.Value= ""
txtSalutation.Value= ""
txtCC.Value= ""
txtAttachments.Value= ""
txtCourier.Value= ""
txtSpacing.Value= 1
Letterhead.spinButton.Value= 1
Letterhead.optBottom.Value= True
txtName.SetFocus
サブの終了
プライベートサブspinButton_SpinDown()
"spinButtonをクリックした場合は、行間隔を減らします
"ゼロに達するまでポイントごとに
txtSpacing>0の場合
txtSpacing= txtSpacing-0.1
終了する場合
サブの終了
プライベートサブspinButton_SpinUp()
"spinButtonをクリックした場合は、行間隔を増やします
"10に達するまでポイントで
If txtSpacing<10 Then
txtSpacing= txtSpacing + 0.1
終了する場合
サブの終了
プライベートサブUserForm_Click()
サブの終了
返信リスト(回答:1)
[ファイル]>[オプション]>[詳細設定]>[ドキュメントコンテンツの表示]からALT+F9を使用してドキュメントのフィールドコードの表示をオンに切り替えると、ドキュメントの本文のどこに情報が表示されているかがわかりますか? あるのではないかと思います
{REFケース名} {REFケース番号}
整理できない場合は、カバーするメールメッセージでこのスレッドを参照して、ドキュメントのコピーを送ってください.問題を調査します.