|
-
Nov 19th, 2001, 06:01 AM
#1
Thread Starter
New Member
Text handling
If I have a form with a text box on it would I be able to open a Word file (.DOC) and display the contents in the text box in the app ?
The reason for this is I have a form that prints, on the form there is a header and footer containing site address, and a whole bunch of terms and conditions. The user needs to be able to edit the details (like when a phone number or address changes.) It seems more logical to have a .DOC file were the user could change whatever they liked, and then to allow the app to access that file for the relavent details.
So the question is. Is this possible ??
Without fear there can be no courage !
-
Nov 19th, 2001, 06:02 AM
#2
-= B u g S l a y e r =-
u can get the text from a word doc, and show it in a textbox, but formatting will be lost ...
-
Nov 19th, 2001, 06:03 AM
#3
Conquistador
Why not open it into a rtf box?
-
Nov 19th, 2001, 06:05 AM
#4
Fanatic Member
one day i will crack the MS word txt format and be able to utilise word docs in my apps (lol)
Use the RTB (rich text box) that would be your best bet
-
Nov 19th, 2001, 06:16 AM
#5
Thread Starter
New Member
Thanks guys, 2 quick questions.
With a RTB format I will be able to keep formatting ?
Will the layout of the "document" be displayed as a mirror image in the text box, or will I have to include some code to handle resizing of fonts and that kind of thing ?
Without fear there can be no courage !
-
Nov 19th, 2001, 06:22 AM
#6
Fanatic Member
my experience is that the Rich text box will keep the original text but as Peet pointed out the formatting will be gone
Fonts should remain the same as the Rich text box supports all installed fonts
but that ole fomatting and anything that word does that a rich text box doesnt eg text boxes inside the doc will not remain (with the text boxes in the doc i belive it throws heaps of line feeds all over the show )
-
Nov 19th, 2001, 06:28 AM
#7
Thread Starter
New Member
What other way would I be able to get a header and footer on the page, with full text formatting ? I am not to worried if the user can not change the header or footer info as I can bill for updates.
Without fear there can be no courage !
-
Nov 19th, 2001, 06:36 AM
#8
-= B u g S l a y e r =-
u could try using an Ole Control on u'r form,
VB Code:
Option Explicit
Private Sub Command1_Click()
OLE1.CreateEmbed "C:\Test.doc"
OLE1.Enabled = False
End Sub
just a suggestion...
-
Nov 19th, 2001, 06:45 AM
#9
Thread Starter
New Member
Thanks Peet
The thought has crossed my mind, I never used an OLE control before.
I suspect that if you put the control on the form, you would be able to retrieve a file to display in the control right ?
Without fear there can be no courage !
-
Nov 19th, 2001, 07:19 AM
#10
Conquistador
i think if you save a word document as an rtf rile, that you can open it - preserving formatting..
Just a theory...
-
Nov 19th, 2001, 08:04 AM
#11
-= B u g S l a y e r =-
Originally posted by bdanney
Thanks Peet
The thought has crossed my mind, I never used an OLE control before.
I suspect that if you put the control on the form, you would be able to retrieve a file to display in the control right ?
yes, try the sample code, think that should do it
-
Nov 19th, 2001, 08:21 AM
#12
_______
<?>
You could open it as a text document and then save it as a word document .
Private Sub Command1_Click()
'pass it the name of the text file and the filename you want it saved as
Call WordDoc("C:\myfile.txt", "C:\NewFile.doc")
End Sub
Public Function WordDoc(sFileName As String, sNewDoc As String) As String
'Open the text file into word and save it as a word doc behind the scenes
Dim objWord As Object
Dim objDoc As Object
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(sFileName)
objWord.Selection.WholeStory
objDoc.SaveAs sNewDoc, 0 'wdFormatDocument
objDoc.Close
objWord.Quit
'
'clear memory of the objects
Set objDoc = Nothing
Set objWord = Nothing
'remove this...
MsgBox "Mission Accomplished"
End Function
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 19th, 2001, 08:23 AM
#13
Conquistador
but he wants to put the document in his text box
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|