掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
VBからWORDに文字を転送するには? (ID:92375)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
参考書を参考にプログラムを組んでみました。しかし、このプログラムだとTextに入っているものを保存したり、Textにファイルを開いてしまいます。Wordの文書を開いたり、Wordの文書をVBから保存する方法をご存知の方、ご教授願います。 Dim myfile As String Private Sub Command1_Click() CommonDialog1.Filter = "テキスト(*.txt)|*.txt|すべて(*.*)|*.*" CommonDialog1.FilterIndex = 1 CommonDialog1.Flags = cdlOFNFileMustExist CommonDialog1.ShowOpen If CommonDialog1.FileName = "" Then Exit Sub myfile = CommonDialog1.FileName FileRead Form1.Caption = "form1" & myfile End Sub Private Sub Command2_Click() filewrite End Sub Private Sub Command3_Click() CommonDialog1.Filter = "テキスト(*.txt)|*.text|すべて(*.*)|*.*" CommonDialog1.FilterIndex = 1 CommonDialog1.Flags = cdlOFNOverwritePrompt CommonDialog1.ShowSave If CommonDialog1.FileName = "" Then Exit Sub myfile = CommonDialog1.FileName filewrite Form1.Caption = "form1" & myfile End Sub Private Sub FileRead() Dim buf As String On Error GoTo errTrap1 Open myfile For Input As #1 Text1.Text = "" While Not EOF(1) Line Input #1, buf Text1.Text = Text1.Text & buf & Chr(13) & Chr(10) Wend Close #1 Exit Sub errTrap1: MsgBox Err.Description Err.Clear End Sub Private Sub Form_Load() Form1.Height = 3510 End Sub Private Sub filewrite() Dim buf As String On Error GoTo errTrap1 Open myfile For Output As #1 Print #1, Text1.Text; Close #1 Exit Sub errTrap1: MsgBox Err.Description Err.Clear End Sub
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.