Solved

Can you create a VB6 execuatable that just executes the code and doesn't go into a form?

Posted on 2006-06-20
5
204 Views
Last Modified: 2010-04-30
We're running a scheduling program that executes excel files with Workbook_Open() macros to run the code such as that below.  I'm constantly getting problems with plugins and references and want to re-write them in some sort of executable.  My question is, can you just write a vb6 or .NET executable that doesn't bring up a form, or is this something I should us VBScript for (something I know very little about) or should I just create a batch file in DOS??  I'd like to use a VB product if possible since it pulls part of the file name from an Excel field.

Any ideas/recommendations would be appreciated.




Sub Workbook_Open()
Dim daterecord As String

'This step copies wmcerpt file
    Workbooks.OpenText FileName:="T:\FFGCRPAC\AcctDownloads\WMCEREPT.txt" _
        , Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier _
        :=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:= _
        False, Comma:=True, Space:=False, Other:=False
    daterecord = [A1].Value
    Workbooks("WMCEREPT.txt").Activate
    ActiveWindow.Close
   
     
        Dim SourceFile1, DestinationFile1
    SourceFile1 = "T:\FFGCRPAC\AcctDownloads\WMCEREPT.txt"
    DestinationFile1 = "T:\FFGCRPAC\AcctDownloads\WMCEHistory\WMCEREPT" & daterecord & ".txt"
  FileCopy SourceFile1, DestinationFile1
   'Kill SourceFile1

    Application.Quit
End Sub
0
Comment
Question by:bfitch01
5 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 16943148
Nope.  By definition, you have to specify a startup form, and it has to open.  As a work-around, what you can do is open that form with .Visible = False, execute all of your code, then close that form when you're done.
0
 
LVL 13

Accepted Solution

by:
rettiseert earned 500 total points
ID: 16943198
Create a new vb6 standard exe project
roght clic on form1 and remove
create a new module and write this code

Sub Main()
   
    'Your code here
   
End Sub

Enter Project->Properties and choose startup object sub main
0
 
LVL 20

Expert Comment

by:alainbryden
ID: 16943238
Rettiseert is correct. If you create a module, you can set it to run with your main sub and you do not need any forms to be displayed at all. It is also possible to create a command line Visual Basic program. Your main can take the input parameters.
0
 

Author Comment

by:bfitch01
ID: 16943581
Works great!

Thanks
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 16944211
Cool.  Learn something new every day.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I need help formating a date variable in my VB.Net application 2 52
Best way to parse out a json string in VB6? 10 170
VBA filters 2 61
Problem to With line 4 57
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

777 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