Solved

VB6 Batch-type file?

Posted on 2003-11-03
7
220 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 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