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
206 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

Technology Partners: 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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 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