Solved

VB6 Batch-type file?

Posted on 2003-11-03
7
217 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
  • 4
  • 3
7 Comments
 
LVL 85

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 85

Expert Comment

by:Mike Tomlinson
ID: 9671470
You can use:

OpenDoc App.Path & "\file1.doc"
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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 85

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 85

Expert Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now