CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 1999
    Posts
    16

    VB Newbie needs help.

    Hello,
    I am a Java programmer and do not know much about VB. I am writing a Word Macro and it needs to do the following:
    Open up a file ("file.doc");
    Read the first line from ("file.doc");
    Close ("file.doc") and open up another file with the first line read
    Thanks ahead of time. All help greatly appreciated. Mr. Bean


  2. #2
    Guest

    Re: VB Newbie needs help.



    'This will load file.txt copy the first line and put it in the second file
    Dim LINEIN as string
    LINEIN = ""

    Open "C:\file.txt" for input as #1
    Open "C:\otherfile.txt" for Output as #2

    Line input #1, LINEIN
    print #2, LINEIN

    Close #1, #2






  3. #3
    Guest

    Re: VB Newbie needs help.

    In Word click Tools, Macro, Record New Macro and then do everything you wanted the macro to do. When finish stop recording, go Tools, Macro, Macros, select Macro you just created. Click on Edit and you'll see the code (VBA) that performs all things you wanted. You can copy it and paste in VB project. After a small editing you can run it from VB. Don't forget to make reference to Word Object Library (Project, References in VB) and create Word object, something like:

    Dim objWord as Word.Application
    set objWord = new Word.Application
    With objWord
    .Visible =true
    'your code from word comes here
    '............
    end with



    Vlad



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

Featured