Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.rtf

Status
Not open for further replies.

CooterBrown

IS-IT--Management
Aug 17, 2001
125
US
I'm writing a macro to open .rtf files and print them to pdf. When I open them using MS Word, the date field is dynamic and changes to Today(). When I open the .rtf in WordPad, the date field is the date that the documents were created. I'm using:
Set pWordApp = New Word.Application in my macro to open and print to pdf. How can I do this without using Word or without changing the date field?
Thanks,
Coot
 
Have you tried to play with the ActiveDocument.Undo method ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That didn't work! 8?(

Any other suggestions?


Public Sub worddox(txthyperlink, filename)
Dim pWordApp As Word.Application
Dim pWordDoc As Word.Document

Set pWordApp = New Word.Application

'On Error Resume Next
Set pWordDoc = pWordApp.Documents.Open(txthyperlink)
'On Error GoTo ERR_ALERT

If Not pWordDoc Is Nothing Then
pWordDoc.Activate
pWordApp.Visible = True
pWordApp.ActiveDocument.Undo
pWordApp.PrintOut Range:=wdPrintAllDocument, Background:=False, OutputFilename:=filename, PrintToFile:=True, Collate:=True



pWordDoc.Close
Set pWordDoc = Nothing

pWordApp.Quit
Set pWordApp = Nothing

End If
Exit Sub

 
You might try opening the rtf AS an rtf, using the OpenFormat method.

Gerry
 
How do I open it as an RTF? Can I open it in WordPad?
 
OpenFormat Property
Returns the file format of the specified file converter. Can be any vailid WdOpenFormat constant, or it can be a unique number that represents an external file converter. Read-only Long.

WdOpenFormat can be one of these WdOpenFormat constants.
wdOpenFormatAllWord
wdOpenFormatAuto
wdOpenFormatDocument
wdOpenFormatEncodedText
wdOpenFormatRTF
wdOpenFormatTemplate
wdOpenFormatText
wdOpenFormatUnicodeText
wdOpenFormatWebPages


expression.OpenFormat
expression Required. An expression that returns a FileConverter object.

Example
This example displays the unique format value and the format name for the converters you can use to open documents.

For Each fc In FileConverters
If fc.CanOpen = True Then _
MsgBox fc.OpenFormat & vbCr & fc.FormatName
Next fc

This example opens the file named "Data.wp" by using the WordPerfect 6x file converter.

Documents.Open FileName:="C:\Data.wp", _
Format:=FileConverters("WordPerfect6x").OpenFormat

_________________
Bob Rashkin
 
Can I open it in WordPad?
I do not understand this. You are using Word...yes??? You are using VBA in Word...yes?? So why do you want to open it in Wordpad?

Gerry
 
Sorry Gerry. I just noticed that when I open the documents manually in WordPad, the dynamic date field does not change. It maintains the date of the original document. I thought if I could open the .rtf's with WordPad and print them to PDF all would be fixed.
 
Uh...I am confused as to your process. You can not use VBA with WordPad. So you are thinking of using Word to open Wordpad, copy stuff THERE and move it back?

Uh....try, as I suggested, opening the file, in Word, but as an RTF.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top