Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
209 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 66

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 2000 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 66

Expert Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

730 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