Solved

VB6 Batch-type file?

Posted on 2003-11-03
7
223 Views
Last Modified: 2010-05-03
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
Comment
Question by:JFrye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 9671073
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
 

Author Comment

by:JFrye
ID: 9671180
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 9671470
You can use:

OpenDoc App.Path & "\file1.doc"
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:JFrye
ID: 9671738
Well, that didn't work. It seems that the file is opened, however Word never opens to actually view the files.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 50 total points
ID: 9671776
Try adding

MSWordApp.Visible = 1

after

MSWordApp.WindowState =  1

The code worked great on my system as is.
0
 

Author Comment

by:JFrye
ID: 9671839
Fantastic! Kudos and 50 points for you!!!
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 9671855
Glad it worked.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question