Ask Experts Questions for FREE Help !
Ask
    qumsiehm's Avatar
    qumsiehm Posts: 2, Reputation: 1
    New Member
     
    #1

    Feb 14, 2009, 05:55 AM
    need a answer
    Hi All..

    listen I'm programing a program and I have a problem!
    that problem is that I need to open a Microsoft document by using visual basic
    I just need to open it like that

    if combo1.text = 1 then ""open the document1.doc from c:\data\document1.doc"
    if combo1.text = 2 then ""open the socument2.doc from c:\data\document2.doc"
    e.t.c...

    then I will make a changes and save it in a document form!
    if u know the answer! Please help!

    Very thankful!
    rwinterton's Avatar
    rwinterton Posts: 289, Reputation: 15
    Full Member
     
    #2

    Feb 14, 2009, 07:02 AM
    Quote Originally Posted by qumsiehm View Post
    Hi All..!

    I'm writing a program and i have a problem!
    That problem is that I need to open a microsoft document by using visual basic
    I just need to open it like that

    if combo1.text = 1 then ""open the document1.doc from c:\data\document1.doc"
    if combo1.text = 2 then ""open the socument2.doc from c:\data\document2.doc"
    e.t.c....

    then i will make a changes and save it in a document form!
    I'm not sure I understand your question.

    There are many ways to open documents. If it is a Microsoft Word document, I'd suggest using COM (ActiveX) to cause Word to open the document.

    If you are editing a text file you can use the Visual Basic "OPEN" command or Visual Basic.NET's StreamReader and StreamWriter classes to open and edit a file. You'll also have to create some object (a memo object, for example) to allow the user to edit the file.

    You should also use a Select Case statement

    Select case Combo1.text
    Case 1:...
    Case 2:...
    Case 3:...
    End Select

    Now, I suspect I haven't answered your question, so please elaborate and I'll do what I can.
    qumsiehm's Avatar
    qumsiehm Posts: 2, Reputation: 1
    New Member
     
    #3

    Feb 14, 2009, 07:43 AM

    U didn't understand my question
    I want to make a program that will work with
    Microsoft word..

    I will make a table in Microsoft word then I will
    Put a code that will open this file as a Microsoft word file using Microsoft office

    I think there is a small and easy code that will do this!
    Thanks!
    rwinterton's Avatar
    rwinterton Posts: 289, Reputation: 15
    Full Member
     
    #4

    Feb 14, 2009, 10:09 AM

    Actually, I thought it might be that. Note what I said:
    "There are many ways to open documents. If it is a Microsoft Word document, I'd suggest using COM (ActiveX) to cause Word to open the document."

    To do that, add a reference to the "Microsoft Word ## Object Library". "##" is the version of Word that is on the computer. That will make the Word functions available to you.

    You can also use CreateObject(). This is VB6 code:
    Dim Word
    Set Word = CreateObject ("word.application")

    This is code from Visual Basic.NET 2008. Other .NET versions are essentially identical and VB6 is similar. . NET doesn't use the "SET" keyword.

    Dim word As New Microsoft.Office.Interop.Word.Application
    Dim doc As Document
    Dim filename as string

    filename = "Test.doc" ' you'll want to pass this in a variable.
    word.Visible = True ' This makes Word visible so the user can edit the document. You may not want this.

    doc = word.Documents.Open(filename)

    ' Manipulate the document as desired,

    doc.Save() ' this saves the document to the file.
    doc.Close() ' this closes the document. It does not close "Word".

    End Sub
    trinopoty's Avatar
    trinopoty Posts: 3, Reputation: 1
    New Member
     
    #5

    Mar 11, 2009, 06:35 AM

    The problem is you have to use the following code:
    if combo1.text = 1 then
    "open the document1.doc from c:\data\document1.doc"
    elseif combo1.text = 2 then "open the socument2.doc from c:\data\document2.doc"
    elseif
    ...
    endif

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

What Am I? Need Answer [ 7 Answers ]

I start at four and move to two and then at dawn I move by three. What Am I?

If the correct answer is May cgs, $15,500 how is the answer correct need to see work [ 1 Answers ]

P23-A The budget committee of Vinning office supply Co. Has assembled the following data. As the business manager, you must prepare the budgeted income statements for May and Jun 2006. A. Sales in April were $42,100.. You forecast that monthly sales will increase 2.0% in May and 2.4% in June.

I need to know this answer [ 1 Answers ]

:confused: what are three different ways to get sick?

Can somebody answer this [ 7 Answers ]

I'm still confuse... Do my friend's bad eat pattern which is anti vegetables can be solve by only doing exercise regularly? Or it is better to eat enough green without having some exercise?


View more questions Search