このページからVBAを適用しようとしていますcopy formatted text into access using vba選択したすべてのファイルまたは特定のフォルダ内のすべてのファイルをループします。これは可能ですか?ありがとう。書式付きWordテキストをAccessにコピーする
0
A
答えて
1
filepicker関数とインポート関数を分割したり、filepicker関数からコレクションまたは配列を戻したりしないでください。
ファイルに
Public Function FilesToOpen() As Collection
' This function will essentially allow you to browse to MS-Word document
' and then store the path of that file for use in the GetWordContent function
Dim fDialog As Object 'Office.FileDialog
Dim varFile As Variant
Set fDialog = Application.FileDialog(3)
Set FilesToOpen = New Collection
With fDialog
.AllowMultiSelect = True
.Title = "Select Word document to import"
.Filters.Clear
.Filters.Add "Word files", "*.doc?"
If _
.Show = True _
Then
For Each varFile In .SelectedItems
FilesToOpen.Add varFile
Next
End If
End With
End Function
を選んで、彼らに私が変更しようとしました
Private Sub cmdGetWordData_Click()
' This subroutine runs on your command button; it will call both the FileToOpen function and GetWordContent subroutine
' to retrieve the text contents of your chosen MS-Word Document.
' It will then store both the path the text contents of of your chosen MS-Word Document in 2 fields in a table in Access.
' NOTE: this code assumes that your Access database has:
' - a table called tblWordDump
' - a memo text field in this table called WordDocDataSrc to store the path of MS-Word file imported
' - a memo text field in this table called WordDocData with the TextFormat property set to "Rich Text",
' which will store the text and text formating of the MS-Word file imported
Dim collFiles As Collection
Dim strWordContent As Variant
' Select files via File Dialogue
Set collFiles = FilesToOpen
Dim oneFile As Variant
' Conditionals when a file was or wasn't selected
If _
collFiles.Count <> 0 _
Then
For Each oneFile In collFiles
DoCmd.GoToRecord , , acNewRec
GetWordContent CStr(oneFile)
Next oneFile
MsgBox "Import Successful", vbInformation Or vbOKOnly
Else
MsgBox "No File Selected", vbExclamation Or vbOKOnly
End If
End Sub
注意を開く:私は教育的価値のために、後者を選択するつもりです
可能な限り小さく、GetWordContent
fで何もしていない統一。
関連する問題
- 1. TFS Workitemの説明を書式付きテキストとしてWordに変換
- 2. 書式付きテキストを銀色のリッチテキストボックスに書式設定4
- 3. Word VBAテーブル - 書式付きセルの内容をコピーしますが、テーブルはコピーしません。
- 4. 書式付きテキストを表示
- 5. Access 2007条件付き日付書式設定
- 6. Word文書を別の文書にコピー
- 7. 書式付きテキストのアウトライン/ストローク
- 8. WordマクロVBA形式のテキストに色付けする
- 9. Word VBA新しい文書にハイライトされたテキストをコピーして書式を保持
- 10. Googleシートで条件付き書式をコピーする
- 11. VBAコードでWord文書のコンテキストと書式をEXCELでコピーする
- 12. Flex 3 - MS WordテキストをFlexアプリケーションにコピー
- 13. zeroclipboard - テキストのコピーと書式設定
- 14. インデックス付きピクセル形式の画像にテキストを書き込む
- 15. MS Wordで縦書きテキストを開く
- 16. 書式付きテキストをSQL .Netに保存します
- 17. MS Access Toggle条件付き書式設定の条件
- 18. 整数の日付を書式付きのテキストに変換する
- 19. MS Word VbaコマンドボタンWord文書にテキストを挿入する
- 20. ExcelからWordにセルをコピーするときにセルの書式を設定する方法
- 21. ggplotによる条件付きテキストの書式設定
- 22. 複数のテキスト値による条件付き書式設定
- 23. Excelで書式付きデータをコピーして書式なしで貼り付ける
- 24. ワークブック間で条件付き書式をコピー
- 25. htmlタグ付きテキストをformated wordファイルに変換する
- 26. 条件付き書式付きセルの条件付きテキストの色
- 27. Excel - 書式の日付の値をテキスト
- 28. Word interopによる書式ペインタ
- 29. Access 2013で条件付き書式を削除できません
- 30. OutlookのメッセージにWord形式をコピーする
可能です。あなたの問題は何ですか? filepickerで複数のファイルを選択していますか?ファイルごとに1回実行するコードを修正しましたか?拡張子が.docまたは.docxのフォルダ内のすべてのファイルを選択していますか? –
私は、ファイルごとにそれを再実行するのではなく、複数のファイルに対して繰り返しています。 AllowMultiSelect = Trueを修正しましたが、選択したすべてのファイル、または特定のフォルダ内のすべてのファイルのうち、最も簡単なものに対して実行します。申し訳ありませんが、私はこのすべてにかなり新しいです。ありがとう。 – niawo