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
205 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
[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
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

Independent Software Vendors: 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!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

740 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