borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Printing Blues)Next Topic (Only at First instance) New Topic New Poll Post Reply
AndreaVB Forum : Printing : word format in 'open "file.doc" for output as #1'
Poster Message
mubarack
Level: Protégé

Registered: 24-07-2004
Posts: 5

icon word format in 'open "file.doc" for output as #1'

Dear Frieds,

I created one word document by using 'open "file.doc" for output as #1'. I also want to format the contents of word by using VB coding (examle : Bold,size....), but I don't know how to do it . pls help me on this issue.

thx in advance.

regards,
mubarack.  

24-07-2004 at 08:24 AM
View Profile Send Email to User Show All Posts | Quote Reply
X3ndou
Level: Graduate

Registered: 31-08-2004
Posts: 9
icon Re: word format in 'open "file.doc" for output as #1'

I am not an expert with anything of this type, but I am pretty sure the word documents use encryption and things inside their files.  Save a word document and vew it in notepad, and see what I mean.  Writing to .doc files is very hard.  You could try writing to an RTF file, but I'm not sure if that would work either because of the quotes VB puts around everything when it writes to files.

Hope this helps.

-X3ndou

31-08-2004 at 09:36 PM
View Profile Send Email to User Show All Posts | Quote Reply
BRMC
Level: VB Lord


Registered: 28-11-2003
Posts: 210
icon Re: word format in 'open "file.doc" for output as #1'

Hi,
u can use by setting in your references to Microsoft Word
or by :



Dim WApp as Object

Set WApp = CreateObject("Word.Application")
WApp.Visible = True



then u can work in vb on your document for example:


Private Sub Command1_Click()
    Dim oWord As Object
    Dim oTmpDoc As Object
    Dim lOrigTop As Long
      
    ' Create a Word document object...
    Set oWord = CreateObject("Word.Application")
    Set oTmpDoc = oWord.Documents.Add
    oWord.Visible = True
   ' Position Word off screen to avoid having document visible...
    lOrigTop = oWord.Top
    oWord.WindowState = 0
    oWord.Top = -3000
    ' copy the contents of the text box to the clipboard
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
    Clipboard.Clear
    Clipboard.SetText Text1.SelText

    ' Assign the text to the document and check spelling...

    With oTmpDoc
        .Content.Paste
        .Activate
        .CheckSpelling
      
       ' After user has made changes, use the clipboard to
       ' transfer the contents back to the text box
        .Content.Copy
        Text1.Text = Clipboard.GetText(vbCFText)
        ' Close the document and exit Word...
        .Saved = True
        .Close
      End With
      Set oTmpDoc = Nothing
      
      oWord.Top = lOrigTop
      oWord.Quit
      Set oWord = Nothing
      
   End Sub



____________________________
I don't mind not going to heaven
As long as they've got cigarettes
in hell

03-09-2004 at 09:52 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Printing : word format in 'open "file.doc" for output as #1'
Previous Topic (Printing Blues)Next Topic (Only at First instance) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder