Link to home
Start Free TrialLog in
Avatar of crmaho01
crmaho01

asked on

Change VBA to VB executable

I currently have a bat file to copy some DAT files and then open excel to format the DAT files, save them as .xls, and then email them.  This will work with no problems on a client machine that has office.  I am now needing to move the process to a server 2000 machine.  Any ideas?


  MY BAT FILE
cd Mania
set DATE=
set TODAY=%DATE:~4,2%%DATE:~7,2%%DATE:~10,4%

copy ..\MANIA.DAT MAN%TODAY%.DAT

copy ..\PMAN.DAT PIZZATRACK%TODAY%.DAT
c:
cd "C:\Program Files\Microsoft Office\OFFICE11"
excel "C:\Documents and Settings\cxm\My Documents\Automation Process\Auto1.xls"
excel "C:\Documents and Settings\cxm\My Documents\Automation Process\Auto2.xls"


  MY VBA Code from the excel files
Range("A1").Select
    ActiveCell.FormulaR1C1 = "Date"
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "Time"
    Range("C1").Select
    ActiveCell.FormulaR1C1 = "Type"
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "Number"
   
    Range("A2").Select
    Application.CutCopyMode = False
    With ActiveSheet.QueryTables.Add(Connection:="TEXT;Z:\Mania\MAN" & Format(Now(), "mmddyyyy") & ".DAT" _
        , Destination:=Range("A2"))
        .Name = "MAN" & Format(Now(), "mmddyyyy")
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = False
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 437
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = True
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(5, 2, 2, 2, 1)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
    ActiveWorkbook.SaveAs ("C:/MAN" & Format(Now(), "mmddyyyy"))
   
    ActiveWorkbook.SendMail "email.address@company.com", "MAN" & Format(Now(), "mmddyyyy")
   
    Application.Quit

ASKER CERTIFIED SOLUTION
Avatar of Sizey
Sizey

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of crmaho01
crmaho01

ASKER

Is there a way that I can email the files without the macros?
It is possible, but I have never done it myself (the closest I've done is create an email without sending)  - from what I have seen it takes far too much work.  It would be easiest to use the functionality of Office if it meets your needs.

Unless you've got a proper version VB, I wouldn't even consider a route other than installing Office.

If you have got VB, it will be a lot of work to get the data formatted suitably too.