Link to home
Start Free TrialLog in
Avatar of JFrye
JFrye

asked on

VB6 Batch-type file?

Is there a way to make an EXE in VB6 that is similar to a DOS batch file?

I have a few different DOC files that I want to open all at once, but the batch file I made will only open one at a time (open file1, close file1 and open file2, etc.).

If it's possible to do, can you point me in the right direction, please? Thanks guys, and girls!
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Here is a generic function to open a word document:

OpenDoc "c:\my documents\address labels.doc"

Private Function OpenDoc(fileName As String)
    Me.MousePointer = vbHourglass
    DoEvents
   
    Dim MSWordApp, MSWordDoc As Object
    On Error Resume Next
   
    Set MSWordApp = GetObject(, "Word.Application")
    If Err.Number <> 0 Then
        Set MSWordApp = CreateObject("Word.Application")
    End If
   
    Set MSWordDoc = MSWordApp.Documents.Open(fileName)
    MSWordApp.Activate
    MSWordApp.WindowState = 1
    Set MSWordDoc = Nothing
    Set MSWordApp = Nothing
   
    Me.MousePointer = vbDefault
End Function
Avatar of JFrye
JFrye

ASKER

Ok, and one more question: For this EXE, if the DOCs are in the same folder as the EXE, can I just put "file1.doc" or will I need "c:\files\galore\file1.doc"?
You can use:

OpenDoc App.Path & "\file1.doc"
Avatar of JFrye

ASKER

Well, that didn't work. It seems that the file is opened, however Word never opens to actually view the files.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JFrye

ASKER

Fantastic! Kudos and 50 points for you!!!
Glad it worked.