ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   open a word file from xl (https://www.excelbanter.com/excel-programming/297103-open-word-file-xl.html)

steve

open a word file from xl
 
how do i open a txt file in word using vba?

file name and path is C:\Test.txt

GJones

open a word file from xl
 
ChangeFileOpenDirectory "C:\"
Documents.Open FileName:="RESETLOG.TXT",
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto



-----Original Message-----
how do i open a txt file in word using vba?

file name and path is C:\Test.txt
.


steve

still need help
 
thanks 4 posting

i tried what you said and it did not work

the version of xl im using is 97,

i hit the object browser and could not find documents in
their. pls help me




-----Original Message-----
ChangeFileOpenDirectory "C:\"
Documents.Open FileName:="RESETLOG.TXT",
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
WritePasswordTemplate:="",

Format:=wdOpenFormatAuto



-----Original Message-----
how do i open a txt file in word using vba?

file name and path is C:\Test.txt
.

.


Dave Peterson[_3_]

still need help
 
On way:

Option Explicit
Sub testme01()

Dim oWord As Object
Dim myWordDocument As String
Dim testStr As String

myWordDocument = "c:\test.txt"

testStr = ""
On Error Resume Next
testStr = Dir(myWordDocument)
On Error GoTo 0
If testStr = "" Then
MsgBox myWordDocument & " doesn't exist"
Exit Sub
End If

On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err Then
Set oWord = CreateObject("Word.Application")
End If

oWord.Visible = True
oWord.Documents.Open myWordDocument

End Sub

steve wrote:

thanks 4 posting

i tried what you said and it did not work

the version of xl im using is 97,

i hit the object browser and could not find documents in
their. pls help me

-----Original Message-----
ChangeFileOpenDirectory "C:\"
Documents.Open FileName:="RESETLOG.TXT",
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
WritePasswordTemplate:="",

Format:=wdOpenFormatAuto



-----Original Message-----
how do i open a txt file in word using vba?

file name and path is C:\Test.txt
.

.


--

Dave Peterson



All times are GMT +1. The time now is 08:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com