[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

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!
0
JFrye
Asked:
JFrye
  • 4
  • 3
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
0
 
JFryeAuthor Commented:
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"?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You can use:

OpenDoc App.Path & "\file1.doc"
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
JFryeAuthor Commented:
Well, that didn't work. It seems that the file is opened, however Word never opens to actually view the files.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Try adding

MSWordApp.Visible = 1

after

MSWordApp.WindowState =  1

The code worked great on my system as is.
0
 
JFryeAuthor Commented:
Fantastic! Kudos and 50 points for you!!!
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Glad it worked.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now