Opening a Non text file in word

  • Thread starter blanic via AccessMonster.com
  • Start date
B

blanic via AccessMonster.com

The below code opens a .txt or .doc file with word and passes the margins
properly, but what I want to do is open the file without changing the file
name if possible.

Dim wdApp As Word.Application
Dim doc As Word.Document

Set wdApp = New Word.Application
wdApp.Visible = True

Set doc = wdApp.Documents.Open("E:\CGinst\RPTS\07\Jan\2331.txt")
'I want to open 2331.31 for instance, instead of it being 2331.txt

With wdApp.ActiveDocument.PageSetup
.TopMargin = 0.35
.BottomMargin = 0.5

End With
 
D

Douglas J. Steele

What's happening when you try? I just tested, and it worked fine for me.
 
S

Stefan Hoffmann

hi,
The below code opens a .txt or .doc file with word and passes the margins
properly, but what I want to do is open the file without changing the file
name if possible.
What is your real problem? Error messages?
Dim wdApp As Word.Application
Dim doc As Word.Document

Set wdApp = New Word.Application
wdApp.Visible = True

Set doc = wdApp.Documents.Open("E:\CGinst\RPTS\07\Jan\2331.txt")
'I want to open 2331.31 for instance, instead of it being 2331.txt
Why don't you try
Set doc = wdApp.Documents.Open("E:\CGinst\RPTS\07\Jan\2331.31")
?


mfG
--> stefan <--
 
B

blanic via AccessMonster.com

Stefan said:
hi,
The below code opens a .txt or .doc file with word and passes the margins
properly, but what I want to do is open the file without changing the file
name if possible.
What is your real problem? Error messages?
Dim wdApp As Word.Application
Dim doc As Word.Document
[quoted text clipped - 4 lines]
Set doc = wdApp.Documents.Open("E:\CGinst\RPTS\07\Jan\2331.txt")
'I want to open 2331.31 for instance, instead of it being 2331.txt
Why don't you try
Set doc = wdApp.Documents.Open("E:\CGinst\RPTS\07\Jan\2331.31")
?

mfG
--> stefan <--


First thanks for the help, when I try stefan's code I get an error that the
document cant be found, it is there, double checked, when I change the .31 to
..txt it works fine, just with the .13 it doesnt.

Any ideas?
 
S

Stefan Hoffmann

hi,
First thanks for the help, when I try stefan's code I get an error that the
document cant be found, it is there, double checked, when I change the .31 to
.txt it works fine, just with the .13 it doesnt.
You mixed up the extensions (.13 vs .31)?


mfG
--> stefan <--
 
Top