Results 1 to 13 of 13

Thread: Text handling

Hybrid View

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    13

    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 !

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    u can get the text from a word doc, and show it in a textbox, but formatting will be lost ...
    -= a peet post =-

  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Why not open it into a rtf box?

  4. #4
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    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

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    13
    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 !

  6. #6
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    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 )

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    13
    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 !

  8. #8
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    u could try using an Ole Control on u'r form,

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     OLE1.CreateEmbed "C:\Test.doc"
    5.     OLE1.Enabled = False
    6. End Sub

    just a suggestion...
    -= a peet post =-

  9. #9

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    13
    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 !

  10. #10
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    i think if you save a word document as an rtf rile, that you can open it - preserving formatting..

    Just a theory...

  11. #11
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    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
    -= a peet post =-

  12. #12
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    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

  13. #13
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    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
  •  



Click Here to Expand Forum to Full Width