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
202 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Works great!

Thanks
0
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
Cool.  Learn something new every day.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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 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…

744 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

17 Experts available now in Live!

Get 1:1 Help Now