Vantage Menu to Formatted Excel File

Using Thad's code I have been able to make my exports more user friendly and
thought I would share my idea.

1) From the menu the person selects an option that launches a program (eg
ud\udAP-Summary.w)
2) Similar to other other code that has been posted a dialog is displayed
with "GO", "CANCEL" and a "STATUS" line.
3) If "GO" is clicked the code dumps the required data to a CSV file in the
VNTGWORK folder
4) When the export is finished the code opens an Excel file (eg
ud\AP-Summary.XLS - Thanks Thad).
5) The XLS contains an Auto_Open macro that opens the CSV, formats it, saves
it as XLS, and then closes itself.

The result, from the Vantage menu a person ends up with a formatted XLS file
on their screen.

The Progress code has been posted before, here is the shell of the Excel
macro.

Sub Auto_Open()

ReportFile = ThisWorkbook.Name

Workbooks.Open FileName:="C:\VntgWork\AP-Sum.csv"

Rem Do some formatting, add borders, page setup etc ...

ActiveWorkbook.SaveAs FileName:="C:\Vntgwork\AP-Sum.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

Workbooks(ReportFile).Activate
ActiveWorkbook.Close

End Sub


[Non-text portions of this message have been removed]
Looking for a dead inventory report: list of all items that have on hand
quantities, but not been transacted in the past 365 days. Report builder is
ok, but ultimately looking for this info in excel. Anything existing?
Thanks.

Amy T. MacKay
Engineering Manager
Parkinson Technologies
amackay@...
(p) 401-762-2100 x 324
(f) 401-762-2295
Do you have Crystal Reports? If so, I might have something that fits your
needs... Also; check out the files section, if you haven't already:
http://groups.yahoo.com/group/vantage/files/


Paul

-----Original Message-----
From: Amy MacKay [mailto:amackay@...]
Sent: Wednesday, September 04, 2002 2:54 PM
To: vantage@yahoogroups.com
Subject: [Vantage] Dead Inventory Report


Looking for a dead inventory report: list of all items that have on hand
quantities, but not been transacted in the past 365 days. Report builder is
ok, but ultimately looking for this info in excel. Anything existing?
Thanks.

Amy T. MacKay
Engineering Manager
Parkinson Technologies
amackay@...
(p) 401-762-2100 x 324
(f) 401-762-2295




Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have
already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and
Crystal Reports and other 'goodies', please goto:
http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto:
http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto:
http://groups.yahoo.com/group/vantage/links

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Looking for a dead inventory report: list of all items that have on hand
quantities, but not been transacted in the past 365 days. Report builder is
ok, but ultimately looking for this info in excel. Anything existing?
Thanks.

Amy T. MacKay
Engineering Manager
Parkinson Technologies
amackay@...
(p) 401-762-2100 x 324
(f) 401-762-2295
Amy,

Attached is the complete progress program file (I'm copying the group, who
won't receive the attachment).

below is the text of the code, which will probably be somewhat garbled in
transit. If anyone else wants me to send them the code, feel free to ask.

You can place the file in the vantage\ud directory and make a shortcut to it
within your vantage menu structure.

HTH,

Thaddeus Jacobs
Information Solutions Developer
Kinematic Automation, Inc.
mailto:tjacobs@...


output to c:\vntgwork\DeadStock.csv.

def var yearago as date.

yearago = today - 365.

export delimiter "," "PartNum" "Description" "OnHandQty".

For each partbin no-lock where partbin.company = "001" and partbin.onhandqty
> 0:
find first parttran no-lock
where
parttran.company = '001' and
parttran.partnum = partbin.partnum and
parttran.trandate GE yearago no-error.

if not available(parttran) then do:
find part no-lock of partbin.
export delimiter "," partbin.partnum part.partdescription
partbin.onhandqty.
end.
end.

output close.


run opendoc("c:\vntgwork\deadstock.csv.").

PROCEDURE OpenDoc:
DEF INPUT PARAM cFileName AS CHAR NO-UNDO.
DEF VARIABLE cParams AS CHAR NO-UNDO initial "".
DEF VARIABLE cDirectory AS CHAR NO-UNDO initial "".
DEF VARIABLE lPrint AS LOG NO-UNDO initial false.

&SCOPED-DEFINE SE_ERR_NOASSOC 31
&SCOPED-DEFINE SE_ERR_ASSOCINCOMPLETE 27

DEF VAR iInstance AS INT NO-UNDO.
DEF VAR cWorkDirectory AS CHAR NO-UNDO.

/* in case parameter cDirectory contains a relative path
it has to be replaced by a fully-qualified path: */

ASSIGN FILE-INFO:FILE-NAME = cDirectory.
IF FILE-INFO:FULL-PATHNAME > "" THEN
cWorkDirectory = FILE-INFO:FULL-PATHNAME.

/* try to execute the document: */

RUN ShellExecuteA(INPUT 0,
INPUT (IF lPrint THEN "print":u ELSE "open":u),
INPUT cFileName,
INPUT cParams,
INPUT cWorkDirectory,
INPUT 1, /* normal mode */
OUTPUT iInstance).

/* if no associated application, run OpenAs dialog: */

IF (iInstance = {&SE_ERR_NOASSOC} OR
iInstance = {&SE_ERR_ASSOCINCOMPLETE})
AND NOT lPrint THEN DO:

/* Ignore cParams because cFileName is a document.
cParams is only valid with executables */
RUN ShellExecuteA (INPUT 0,
INPUT "open":u,
INPUT "rundll32.exe":u,
INPUT "shell32.dll,OpenAs_RunDLL ":u + cFileName,
INPUT cWorkDirectory,
INPUT 1,
OUTPUT iInstance).
END. /* if */

/* test for error: */

RUN TestErrorCode(iInstance).
IF RETURN-VALUE > "" THEN
MESSAGE RETURN-VALUE
VIEW-AS ALERT-BOX ERROR BUTTON OK.

END PROCEDURE.
/***************************************************************************
*/

PROCEDURE ShellExecuteA EXTERNAL "shell32":U :
DEFINE INPUT PARAMETER HWND AS LONG.
DEFINE INPUT PARAMETER lpOperation AS CHAR.
DEFINE INPUT PARAMETER lpFile AS CHAR.
DEFINE INPUT PARAMETER lpParameters AS CHAR.
DEFINE INPUT PARAMETER lpDirectory AS CHAR.
DEFINE INPUT PARAMETER nShowCmd AS LONG.
DEFINE RETURN PARAMETER hInstance AS LONG.
END PROCEDURE.


PROCEDURE TestErrorCode :
DEFINE INPUT PARAMETER iCode AS INTEGER.
DEF VAR cTxt AS CHAR NO-UNDO.

IF iCode < 0 OR iCode > 32 THEN RETURN "". /* no error */

CASE iCode :
WHEN 0 THEN cTxt = "The operating system is out of memory or
resources.":T132.
WHEN 2 THEN cTxt = "The specified file was not found":T132.
WHEN 3 THEN cTxt = "The specified path was not found.":T132.
WHEN 5 THEN cTxt = "The operating system denied access to the specified
file.":T132.
WHEN 8 THEN cTxt = "There was not enough memory to complete the
operation.":T132.
WHEN 10 THEN cTxt = "Wrong Windows version":T132.
WHEN 11 THEN cTxt = "The .EXE file is invalid (non-Win32 .EXE or error in
.EXE image).":T132.
WHEN 12 THEN cTxt = "Application was designed for a different operating
system.":T132.
WHEN 13 THEN cTxt = "Application was designed for MS-DOS 4.0.":T132.
WHEN 15 THEN cTxt = "Attempt to load a real-mode program.":T132.
WHEN 16 THEN cTxt = "Attempt to load a second instance of an application
with non-readonly data segments.":T132.
WHEN 19 THEN cTxt = "Attempt to load a compressed application file.":T132.
WHEN 20 THEN cTxt = "Dynamic-link library (DLL) file failure.":T132.
WHEN 26 THEN cTxt = "A sharing violation occurred.":T132.
WHEN 27 THEN cTxt = "The filename association is incomplete or
invalid.":T132.
WHEN 28 THEN cTxt = "The DDE transaction could not be completed because
the request timed out.":T132.
WHEN 29 THEN cTxt = "The DDE transaction failed.":T132.
WHEN 30 THEN cTxt = "The DDE transaction could not be completed because
other DDE transactions were being processed.":T132.
WHEN 31 THEN cTxt = "There is no application associated with the given
filename extension.":T132.
WHEN 32 THEN cTxt = "The specified dynamic-link library was not
found.":T132.
OTHERWISE cTxt = "Undocumented error code returned":T132.
END.

RETURN cTxt.

END PROCEDURE.



[Non-text portions of this message have been removed]
I would like a copy.

Edward F. Fox, Jr., CPA
Controller
Maxson Automatic Machinery Company
Phone: 401-596-0162 x110
Fax: 401-596-1050
www.maxsonautomatic.com


-----Original Message-----
From: Thad Jacobs [mailto:tjacobs@...]
Sent: Wednesday, September 04, 2002 3:17 PM
To: 'amackay@...'
Cc: 'vantage@yahoogroups.com'
Subject: RE: [Vantage] Dead Inventory Report


Amy,

Attached is the complete progress program file (I'm copying the group, who
won't receive the attachment).

below is the text of the code, which will probably be somewhat garbled in
transit. If anyone else wants me to send them the code, feel free to ask.

You can place the file in the vantage\ud directory and make a shortcut to it
within your vantage menu structure.

HTH,

Thaddeus Jacobs
Information Solutions Developer
Kinematic Automation, Inc.
mailto:tjacobs@...


output to c:\vntgwork\DeadStock.csv.

def var yearago as date.

yearago = today - 365.

export delimiter "," "PartNum" "Description" "OnHandQty".

For each partbin no-lock where partbin.company = "001" and partbin.onhandqty
> 0:
find first parttran no-lock
where
parttran.company = '001' and
parttran.partnum = partbin.partnum and
parttran.trandate GE yearago no-error.

if not available(parttran) then do:
find part no-lock of partbin.
export delimiter "," partbin.partnum part.partdescription
partbin.onhandqty.
end.
end.

output close.


run opendoc("c:\vntgwork\deadstock.csv.").

PROCEDURE OpenDoc:
DEF INPUT PARAM cFileName AS CHAR NO-UNDO.
DEF VARIABLE cParams AS CHAR NO-UNDO initial "".
DEF VARIABLE cDirectory AS CHAR NO-UNDO initial "".
DEF VARIABLE lPrint AS LOG NO-UNDO initial false.

&SCOPED-DEFINE SE_ERR_NOASSOC 31
&SCOPED-DEFINE SE_ERR_ASSOCINCOMPLETE 27

DEF VAR iInstance AS INT NO-UNDO.
DEF VAR cWorkDirectory AS CHAR NO-UNDO.

/* in case parameter cDirectory contains a relative path
it has to be replaced by a fully-qualified path: */

ASSIGN FILE-INFO:FILE-NAME = cDirectory.
IF FILE-INFO:FULL-PATHNAME > "" THEN
cWorkDirectory = FILE-INFO:FULL-PATHNAME.

/* try to execute the document: */

RUN ShellExecuteA(INPUT 0,
INPUT (IF lPrint THEN "print":u ELSE "open":u),
INPUT cFileName,
INPUT cParams,
INPUT cWorkDirectory,
INPUT 1, /* normal mode */
OUTPUT iInstance).

/* if no associated application, run OpenAs dialog: */

IF (iInstance = {&SE_ERR_NOASSOC} OR
iInstance = {&SE_ERR_ASSOCINCOMPLETE})
AND NOT lPrint THEN DO:

/* Ignore cParams because cFileName is a document.
cParams is only valid with executables */
RUN ShellExecuteA (INPUT 0,
INPUT "open":u,
INPUT "rundll32.exe":u,
INPUT "shell32.dll,OpenAs_RunDLL ":u + cFileName,
INPUT cWorkDirectory,
INPUT 1,
OUTPUT iInstance).
END. /* if */

/* test for error: */

RUN TestErrorCode(iInstance).
IF RETURN-VALUE > "" THEN
MESSAGE RETURN-VALUE
VIEW-AS ALERT-BOX ERROR BUTTON OK.

END PROCEDURE.
/***************************************************************************
*/

PROCEDURE ShellExecuteA EXTERNAL "shell32":U :
DEFINE INPUT PARAMETER HWND AS LONG.
DEFINE INPUT PARAMETER lpOperation AS CHAR.
DEFINE INPUT PARAMETER lpFile AS CHAR.
DEFINE INPUT PARAMETER lpParameters AS CHAR.
DEFINE INPUT PARAMETER lpDirectory AS CHAR.
DEFINE INPUT PARAMETER nShowCmd AS LONG.
DEFINE RETURN PARAMETER hInstance AS LONG.
END PROCEDURE.


PROCEDURE TestErrorCode :
DEFINE INPUT PARAMETER iCode AS INTEGER.
DEF VAR cTxt AS CHAR NO-UNDO.

IF iCode < 0 OR iCode > 32 THEN RETURN "". /* no error */

CASE iCode :
WHEN 0 THEN cTxt = "The operating system is out of memory or
resources.":T132.
WHEN 2 THEN cTxt = "The specified file was not found":T132.
WHEN 3 THEN cTxt = "The specified path was not found.":T132.
WHEN 5 THEN cTxt = "The operating system denied access to the specified
file.":T132.
WHEN 8 THEN cTxt = "There was not enough memory to complete the
operation.":T132.
WHEN 10 THEN cTxt = "Wrong Windows version":T132.
WHEN 11 THEN cTxt = "The .EXE file is invalid (non-Win32 .EXE or error in
.EXE image).":T132.
WHEN 12 THEN cTxt = "Application was designed for a different operating
system.":T132.
WHEN 13 THEN cTxt = "Application was designed for MS-DOS 4.0.":T132.
WHEN 15 THEN cTxt = "Attempt to load a real-mode program.":T132.
WHEN 16 THEN cTxt = "Attempt to load a second instance of an application
with non-readonly data segments.":T132.
WHEN 19 THEN cTxt = "Attempt to load a compressed application file.":T132.
WHEN 20 THEN cTxt = "Dynamic-link library (DLL) file failure.":T132.
WHEN 26 THEN cTxt = "A sharing violation occurred.":T132.
WHEN 27 THEN cTxt = "The filename association is incomplete or
invalid.":T132.
WHEN 28 THEN cTxt = "The DDE transaction could not be completed because
the request timed out.":T132.
WHEN 29 THEN cTxt = "The DDE transaction failed.":T132.
WHEN 30 THEN cTxt = "The DDE transaction could not be completed because
other DDE transactions were being processed.":T132.
WHEN 31 THEN cTxt = "There is no application associated with the given
filename extension.":T132.
WHEN 32 THEN cTxt = "The specified dynamic-link library was not
found.":T132.
OTHERWISE cTxt = "Undocumented error code returned":T132.
END.

RETURN cTxt.

END PROCEDURE.



[Non-text portions of this message have been removed]



Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have
already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and
Crystal Reports and other 'goodies', please goto:
http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto:
http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto:
http://groups.yahoo.com/group/vantage/links

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
oops.... In order to run from vantage I think you'll have to change the
filename to udDeadStock.p (and update menu structure maintenance
accordingly).

The program is written progress 4gl, which is the native language of the
progress database. It exports the records to a csv file, then tells windows
to open the file with its associated program.

You can also run the program from any workstation that has the progress
client installed, using a shortcut target line similar to the following
(you'll have to change the drive letter, EPIC50 service name, and
vantageservername to match your system):

V:\PROGRESS\bin\prowin32.exe -db vantage.db -N TCP -S EPIC50 -H
VANTAGESERVERNAME -p v:\vantage\ud\udDeadStock.p

Thaddeus Jacobs
Information Solutions Developer
Kinematic Automation, Inc.
mailto:tjacobs@...


-----Original Message-----
From: Amy MacKay [mailto:amackay@...]
Sent: Wednesday, September 04, 2002 1:02 PM
To: 'Thad Jacobs'
Subject: RE: [Vantage] Dead Inventory Report


Thanks. I tried this. When I connect it in menu structure maintenance, it
either disappears, or I get a message saying "program doesn't belong in this
folder." Can you give me more info on what type of program you sent and how
I can run it? Thank you.

Amy


Amy T. MacKay
Engineering Manager
Parkinson Technologies
amackay@...
(p) 401-762-2100 x 324
(f) 401-762-2295


-----Original Message-----
From: Thad Jacobs [mailto:tjacobs@...]
Sent: Wednesday, September 04, 2002 3:17 PM
To: 'amackay@...'
Cc: 'vantage@yahoogroups.com'
Subject: RE: [Vantage] Dead Inventory Report


Amy,

Attached is the complete progress program file (I'm copying the group, who
won't receive the attachment).

below is the text of the code, which will probably be somewhat garbled in
transit. If anyone else wants me to send them the code, feel free to ask.

You can place the file in the vantage\ud directory and make a shortcut to it
within your vantage menu structure.

HTH,

Thaddeus Jacobs
Information Solutions Developer
Kinematic Automation, Inc.
mailto:tjacobs@...


output to c:\vntgwork\DeadStock.csv.

def var yearago as date.

yearago = today - 365.

export delimiter "," "PartNum" "Description" "OnHandQty".

For each partbin no-lock where partbin.company = "001" and partbin.onhandqty
> 0:
find first parttran no-lock
where
parttran.company = '001' and
parttran.partnum = partbin.partnum and
parttran.trandate GE yearago no-error.

if not available(parttran) then do:
find part no-lock of partbin.
export delimiter "," partbin.partnum part.partdescription
partbin.onhandqty.
end.
end.

output close.


run opendoc("c:\vntgwork\deadstock.csv.").

PROCEDURE OpenDoc:
DEF INPUT PARAM cFileName AS CHAR NO-UNDO.
DEF VARIABLE cParams AS CHAR NO-UNDO initial "".
DEF VARIABLE cDirectory AS CHAR NO-UNDO initial "".
DEF VARIABLE lPrint AS LOG NO-UNDO initial false.

&SCOPED-DEFINE SE_ERR_NOASSOC 31
&SCOPED-DEFINE SE_ERR_ASSOCINCOMPLETE 27

DEF VAR iInstance AS INT NO-UNDO.
DEF VAR cWorkDirectory AS CHAR NO-UNDO.

/* in case parameter cDirectory contains a relative path
it has to be replaced by a fully-qualified path: */

ASSIGN FILE-INFO:FILE-NAME = cDirectory.
IF FILE-INFO:FULL-PATHNAME > "" THEN
cWorkDirectory = FILE-INFO:FULL-PATHNAME.

/* try to execute the document: */

RUN ShellExecuteA(INPUT 0,
INPUT (IF lPrint THEN "print":u ELSE "open":u),
INPUT cFileName,
INPUT cParams,
INPUT cWorkDirectory,
INPUT 1, /* normal mode */
OUTPUT iInstance).

/* if no associated application, run OpenAs dialog: */

IF (iInstance = {&SE_ERR_NOASSOC} OR
iInstance = {&SE_ERR_ASSOCINCOMPLETE})
AND NOT lPrint THEN DO:

/* Ignore cParams because cFileName is a document.
cParams is only valid with executables */
RUN ShellExecuteA (INPUT 0,
INPUT "open":u,
INPUT "rundll32.exe":u,
INPUT "shell32.dll,OpenAs_RunDLL ":u + cFileName,
INPUT cWorkDirectory,
INPUT 1,
OUTPUT iInstance).
END. /* if */

/* test for error: */

RUN TestErrorCode(iInstance).
IF RETURN-VALUE > "" THEN
MESSAGE RETURN-VALUE
VIEW-AS ALERT-BOX ERROR BUTTON OK.

END PROCEDURE.
/***************************************************************************
*/

PROCEDURE ShellExecuteA EXTERNAL "shell32":U :
DEFINE INPUT PARAMETER HWND AS LONG.
DEFINE INPUT PARAMETER lpOperation AS CHAR.
DEFINE INPUT PARAMETER lpFile AS CHAR.
DEFINE INPUT PARAMETER lpParameters AS CHAR.
DEFINE INPUT PARAMETER lpDirectory AS CHAR.
DEFINE INPUT PARAMETER nShowCmd AS LONG.
DEFINE RETURN PARAMETER hInstance AS LONG.
END PROCEDURE.


PROCEDURE TestErrorCode :
DEFINE INPUT PARAMETER iCode AS INTEGER.
DEF VAR cTxt AS CHAR NO-UNDO.

IF iCode < 0 OR iCode > 32 THEN RETURN "". /* no error */

CASE iCode :
WHEN 0 THEN cTxt = "The operating system is out of memory or
resources.":T132.
WHEN 2 THEN cTxt = "The specified file was not found":T132.
WHEN 3 THEN cTxt = "The specified path was not found.":T132.
WHEN 5 THEN cTxt = "The operating system denied access to the specified
file.":T132.
WHEN 8 THEN cTxt = "There was not enough memory to complete the
operation.":T132.
WHEN 10 THEN cTxt = "Wrong Windows version":T132.
WHEN 11 THEN cTxt = "The .EXE file is invalid (non-Win32 .EXE or error in
.EXE image).":T132.
WHEN 12 THEN cTxt = "Application was designed for a different operating
system.":T132.
WHEN 13 THEN cTxt = "Application was designed for MS-DOS 4.0.":T132.
WHEN 15 THEN cTxt = "Attempt to load a real-mode program.":T132.
WHEN 16 THEN cTxt = "Attempt to load a second instance of an application
with non-readonly data segments.":T132.
WHEN 19 THEN cTxt = "Attempt to load a compressed application file.":T132.
WHEN 20 THEN cTxt = "Dynamic-link library (DLL) file failure.":T132.
WHEN 26 THEN cTxt = "A sharing violation occurred.":T132.
WHEN 27 THEN cTxt = "The filename association is incomplete or
invalid.":T132.
WHEN 28 THEN cTxt = "The DDE transaction could not be completed because
the request timed out.":T132.
WHEN 29 THEN cTxt = "The DDE transaction failed.":T132.
WHEN 30 THEN cTxt = "The DDE transaction could not be completed because
other DDE transactions were being processed.":T132.
WHEN 31 THEN cTxt = "There is no application associated with the given
filename extension.":T132.
WHEN 32 THEN cTxt = "The specified dynamic-link library was not
found.":T132.
OTHERWISE cTxt = "Undocumented error code returned":T132.
END.

RETURN cTxt.

END PROCEDURE.