'$INCLUDE "XLConst.bas" '$INCLUDE "bcx_grid.inc" $INCLUDE TYPE Vendor szName$ szAdd1$ szAdd2$ szCity$ szState$ szZip$ szCountry$ szContact$ szPhone$ szExt$ szFax$ szTax$ END TYPE GLOBAL Vend[300] AS Vendor CONST ID_TOOLBAR = 2000 'define the style of the border CONST xlDiagonalDown = 5 CONST xlDiagonalUp = 6 CONST xlEdgeLeft = 7 CONST xlEdgeTop = 8 CONST xlEdgeBottom = 9 CONST xlEdgeRight = 10 CONST xlInsideHorizontal = 12 CONST xlInsideVertical = 11 CONST msoTrue = -1 CONST msoLineSingle = 1 CONST msoLineRoundDot = 3 'make borders have the default color index CONST xlAutomatic = -4105 'define the placement of border pieces CONST xlNone = -4142 'Note this is the same as xlLineStyleNone CONST xlContinuous = 1 CONST xlDash = -4115 CONST xlDashDot = 4 CONST xlDashDotDot = 5 CONST xlDot = -4118 CONST xlDouble = -4119 CONST xlSlantDashDot = 13 'define the weight of the border CONST xlHairLine = 1 CONST xlMedium = -4138 CONST xlThick = 4 CONST xlThin = 2 GLOBAL G_hMod AS HMODULE 'RaGrid instance handle GLOBAL hGrid1 AS HWND GLOBAL hCombo AS HWND GLOBAL hPOhWnd AS HWND GLOBAL hMainDlg AS HWND GLOBAL hToolbar AS HWND GLOBAL G_Color AS ROWCOLOR GLOBAL G_Time$ GLOBAL G_Vendor$ GLOBAL G_pos AS INTEGER GLOBAL xl AS OBJECT GLOBAL XLVisible AS BOOL GLOBAL hkbHook AS HHOOK FUNCTION WinMain() DIM icex AS INITCOMMONCONTROLSEX icex.dwSize = sizeof(INITCOMMONCONTROLSEX) icex.dwICC = ICC_LISTVIEW_CLASSES|ICC_BAR_CLASSES|ICC_COOL_CLASSES InitCommonControlsEx(&icex) FUNCTION = BCX_MDIALOG(POPreviewPrint ,"Exxel PO Preview & Print", 0, 134, 46, 494, 276, 0, 0, "MS Sans Serif", 8) END FUNCTION BEGIN MODAL DIALOG AS POPreviewPrint SELECT CASE CBMSG CASE WM_INITDIALOG DIM coltype XLVisible = TRUE hMainDlg = hWnd G_Color.backcolor = RGB(255,255,225) G_Color.textcolor = RGB(0,0,0) 'load dll G_hMod = LOADLIBRARY("RAGrid.dll") IF G_hMod = NULL THEN MSGBOX "The RaGrid.DLL could not be loaded.", "Error loading RaGrid", MB_OK|MB_ICONERROR END IF BCX_LABEL("PO No.", hWnd, 1000, 12, 24, 26, 8) BCX_INPUT("", hWnd, 1001, 42, 22, 60, 12) BCX_DATEPICK("", hWnd, 1002, 142, 22, 60, 12, WS_CHILD | WS_TABSTOP | WS_VISIBLE | DTS_SHORTDATECENTURYFORMAT) hGrid1 = BCX_CONTROL("RAGRID", hWnd, "", 1003, 12, 40, 376, 228, 0x50010000|STYLE_HGRIDLINES|STYLE_VGRIDLINES|STYLE_NOSEL,0x200) BCX_LABEL("Date", hWnd, 1004, 108, 24, 20, 8) BCX_COMBOBOX("", hWnd, 1005, 250, 22, 140, 250, WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP) BCX_LABEL("Vendor List", hWnd, 1006, 208, 24, 38, 8) BCX_BUTTON("Send to XL", hWnd, 1007, 398, 34, 86, 18) BCX_BUTTON("Print Preview", hWnd, 1008, 398, 62, 86, 18) BCX_BUTTON("Quit", hWnd, 1009, 398, 90, 86, 18) DIM RAW styles[] = {0,0,0,0,0,0,0,0,0} hToolbar = BCX_TOOLBAR(hWnd, ID_TOOLBAR, 6, "-1|2|3|4||5|6|", styles, BCX_LOADBMP("",1000,1),0,16,16, _ WS_CHILD | WS_VISIBLE | WS_BORDER | CCS_NODIVIDER | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS) SendMessage(hGrid1, WM_SETFONT, GetStockObject(DEFAULT_GUI_FONT),0) SendMessage(hGrid1, GM_SETBACKCOLOR, G_Color.backcolor, 0) DIM Grid_Hinstance AS HINSTANCE 'DW Grid_Hinstance = (HINSTANCE)GetWindowLong(hGrid1, GWL_HINSTANCE) hkbHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProc, Grid_Hinstance, 0) IF NOT hkbHook THEN DisplayLastError() hCombo = GetDlgItem(hMainDlg,1005) hPOhWnd = GetDlgItem(hMainDlg,1001) AddColumn(hGrid1, "Qty", TYPE_EDITLONG) AddColumn(hGrid1, "Part No.", TYPE_EDITTEXT) AddColumn(hGrid1, "Desc.", TYPE_EDITTEXT) AddColumn(hGrid1, "Unit", TYPE_EDITTEXT) AddColumn(hGrid1, "Cost", TYPE_EDITTEXT) SendMessage(hGrid1, GM_SETCOLWIDTH, 0, 30 ) SendMessage(hGrid1, GM_SETCOLWIDTH, 1, 100) SendMessage(hGrid1, GM_SETCOLWIDTH, 2, 250) SendMessage(hGrid1, GM_SETCOLWIDTH, 3, 75 ) SendMessage(hGrid1, GM_SETCOLWIDTH, 4, 104) CALL FillVendorList() DIM tim AS SYSTEMTIME '04/20/08 DIM tmp$ tmp$ = TRIM$(STRTOKEN$(NOW$, SPC$ , 1)) tim.wMonth = VAL(STRTOKEN$(tmp$, "/" , 1)) tim.wDay = VAL(STRTOKEN$(tmp$, "/" , 2)) tim.wYear = 2000 + VAL(STRTOKEN$(tmp$, "/" , 3)) G_Time$ = TRIM$(STR$(tim.wMonth)) + "/" + TRIM$(STR$(tim.wDay)) + "/" + TRIM$(STR$(tim.wYear)) SendMessage (GetDlgItem(hMainDlg,1002), DTM_SETSYSTEMTIME, GDT_VALID , &tim) SendMessage(hGrid1, GM_ADDROW, 0, NULL) CENTER(hWnd) FUNCTION = TRUE CASE WM_NOTIFY DIM RAW lpNMFormat = (LPNMDATETIMEFORMAT)lParam AS LPNMDATETIMEFORMAT IF lpNMFormat->nmhdr.idFrom = 1002 THEN IF lpNMFormat->nmhdr.code = DTN_DATETIMECHANGE THEN DIM RAW lpChange = (LPNMDATETIMECHANGE)lParam AS LPNMDATETIMECHANGE DIM tim AS SYSTEMTIME SendMessage(GetDlgItem(hMainDlg,1002), DTM_GETSYSTEMTIME, 0, &tim) G_Time$ = TRIM$(STR$(tim.wMonth)) + "/" + TRIM$(STR$(tim.wDay)) + "/" + TRIM$(STR$(tim.wYear)) FUNCTION = 0 END IF END IF DIM RAW gn = (LPGRIDNOTIFY)lParam AS LPGRIDNOTIFY IF gn->nmhdr.idFrom = ID_TOOLBAR THEN IF gn->nmhdr.code = NM_CLICK THEN DIM pnmm AS NMMOUSE PTR pnmm = (NMMOUSE PTR)lParam CALL ToolBar1Btn_Click(pnmm->dwItemSpec) EXIT FUNCTION END IF END IF IF gn->nmhdr.idFrom = 1003 THEN 'grid1 IF gn->nmhdr.code = GN_HEADERCLICK THEN SendMessage(hGrid1, GM_COLUMNSORT, gn->col, SORT_INVERT) END IF IF gn->nmhdr.code = GN_BUTTONCLICK THEN DIM ccol ccol = SendMessage(hGrid1, GM_GETCURCOL, 0, 0) 'IF FieldName$[ccol+1] = "VendorID" THEN 'BCX_DIALOG(DlgProc2,"Vendor List",0,20,24,374,170,0,0,"MS Sans Serif",8) 'ELSE 'END IF END IF IF gn->nmhdr.code = GN_AFTERSELCHANGE THEN DIM crow DIM rowclr AS ROWCOLOR crow = SendMessage(hGrid1, GM_GETCURROW, 0, 0) rowclr.backcolor = RGB(241,233,225) rowclr.textcolor = RGB(0,0,255) SendMessage(hGrid1, GM_SETROWCOLOR, crow, &rowclr) END IF IF gn->nmhdr.code = GN_BEFORESELCHANGE THEN DIM crow DIM rowclr AS ROWCOLOR crow = SendMessage(hGrid1, GM_GETCURROW, 0, 0) rowclr.backcolor = G_Color.backcolor rowclr.textcolor = G_Color.textcolor SendMessage(hGrid1, GM_SETROWCOLOR, crow, &rowclr) END IF END IF CASE WM_SIZE 'frm SendMessage(hToolbar, TB_AUTOSIZE, 0, 0) CASE WM_COMMAND SELECT CASE CBCTL ' ************************************************************************* CASE 1009 ' hButton3 IF CBCTLMSG = BN_CLICKED THEN IF hkbHook THEN UnhookWindowsHookEx(hkbHook) CLOSEDIALOG END IF ' ************************************************************************* CASE 1005 CALL Combo1_Click(HIWORD(wParam)) : EXIT FUNCTION ' ************************************************************************* CASE 1007 XLVisible = TRUE 'CALL WriteForm() CALL RunForm() CASE 1008 XLVisible = TRUE 'CALL WriteForm() CALL RunForm() END SELECT END SELECT END DIALOG FUNCTION KeyboardHookProc(nCode AS INTEGER, wParam AS WPARAM, lParam AS LPARAM) AS LRESULT CALLBACK DIM p AS PKBDLLHOOKSTRUCT DIM row, col, count, currow DIM ret IF nCode = HC_ACTION THEN SELECT CASE wParam CASE WM_KEYDOWN, WM_SYSKEYDOWN p = (PKBDLLHOOKSTRUCT)lParam col = Ra_GetCurCol(hGrid1) row = Ra_GetCurRow(hGrid1) count = Ra_GetRowCount(hGrid1) IF col = 4 AND p->vkCode = 13 THEN IF count = row + 1 THEN SendMessage(hGrid1, GM_ADDROW, 0, NULL) END IF print "Current row is " + row + " Rowcount is " + count row++ : col = 0 Ra_SetCurRow(hGrid1,row) Ra_SetCurCol(hGrid1,col) END IF FUNCTION = CallNextHookEx(NULL, nCode, wParam, lParam) END SELECT END IF FUNCTION = CallNextHookEx(NULL, nCode, wParam, lParam) END FUNCTION '########################################################## '### Displays last API call error '### DisplayLastError() '########################################################## sub DisplayLastError() dim szErrorMsg as PVOID dim szErrorNo$ if GetLastError() <> 0 then ' allow windows to allocate the buffer FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | _ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, _ GetLastError(), 0, (LPTSTR)&szErrorMsg, 0, NULL) ' convert number into displayable text, then send it to the screen wsprintf(szErrorNo$, "Error: %d", GetLastError()) MessageBox(0, szErrorMsg$, szErrorNo$, MB_OK or MB_ICONSTOP) end if end sub SUB Combo1_Click(nmsg AS WORD) IF nmsg = CBN_SELCHANGE THEN 'Get the Vendor Name G_pos = SendMessage(hCombo, CB_GETCURSEL, 0, 0) SendMessage (hCombo, CB_GETLBTEXT, G_pos, G_Vendor$) END IF END SUB SUB FillVendorList() DIM LineIn$, SzLineNo$, SzName$ DIM j j = 0 IF EXIST("vendor.txt") THEN OPEN "vendor.txt" FOR INPUT AS Fp1 WHILE NOT EOF(Fp1) LINE INPUT Fp1, LineIn$ IF TRIM$(LineIn$) = "----------------------" THEN j++ : ITERATE SzLineNo$ = TRIM$(STRTOKEN$(LineIn$, "=" , 1)) SzName$ = TRIM$(STRTOKEN$(LineIn$, "=" , 2)) SELECT CASE SzLineNo$ CASE "1" IF *SzName$ THEN Vend[j].szName$ = SzName$ SendMessage(hCombo, CB_ADDSTRING, 0, Vend[j].szName$) END IF CASE "2" IF *SzName$ THEN Vend[j].szAdd1$ = SzName$ ELSE Vend[j].szAdd1$ = " " SzName$ = "" CASE "3" IF *SzName$ THEN Vend[j].szAdd2$ = SzName$ ELSE Vend[j].szAdd2$ = " " SzName$ = "" CASE "4" IF *SzName$ THEN Vend[j].szCity$ = SzName$ ELSE Vend[j].szCity$ = " " SzName$ = "" CASE "5" IF *SzName$ THEN Vend[j].szState$ = SzName$ ELSE Vend[j].szState$ = " " SzName$ = "" CASE "6" IF *SzName$ THEN Vend[j].szZip$ = SzName$ ELSE Vend[j].szZip$ = " " SzName$ = "" CASE "7" IF *SzName$ THEN Vend[j].szCountry$ = SzName$ ELSE Vend[j].szCountry$ = " " SzName$ = "" CASE "8" IF *SzName$ THEN Vend[j].szContact$ = SzName$ ELSE Vend[j].szContact$ = " " SzName$ = "" CASE "9" IF *SzName$ THEN Vend[j].szPhone$ = SzName$ ELSE Vend[j].szPhone$ = " " SzName$ = "" CASE "10" IF *SzName$ THEN Vend[j].szExt$ = SzName$ ELSE Vend[j].szExt$ = " " SzName$ = "" CASE "11" IF *SzName$ THEN Vend[j].szFax$ = SzName$ ELSE Vend[j].szFax$ = " " SzName$ = "" END SELECT WEND CLOSE Fp1 SNDMSG(GetDlgItem(hMainDlg,1005),CB_SETCURSEL,0,0) END IF END SUB SUB ToolBar1Btn_Click(BtnIndex AS DWORD) SELECT CASE BtnIndex CASE ID_TOOLBAR + 1 '<< SendMessage(hGrid1, GM_SETCURROW, 0, 0) CASE ID_TOOLBAR + 2 '< DIM crow crow = SendMessage(hGrid1, GM_GETCURROW, 0, 0) IF crow > 0 THEN SendMessage(hGrid1, GM_SETCURROW, crow-1, 0) CASE ID_TOOLBAR + 3 '> DIM crow, cnt cnt = SendMessage(hGrid1, GM_GETROWCOUNT, 0, 0) crow = SendMessage(hGrid1, GM_GETCURROW, 0, 0) IF (crow + 1) < cnt THEN SendMessage(hGrid1, GM_SETCURROW, crow+1, 0) CASE ID_TOOLBAR + 4 '>> DIM cnt cnt = SendMessage(hGrid1, GM_GETROWCOUNT, 0, 0) SendMessage(hGrid1, GM_SETCURROW, cnt-1, 0) CASE ID_TOOLBAR + 5 '+ DIM cnt SendMessage(hGrid1, GM_ADDROW, 0, NULL) cnt = SendMessage(hGrid1, GM_GETROWCOUNT, 0, 0) SendMessage(hGrid1, GM_SETCURROW, cnt-1, 0) CASE ID_TOOLBAR + 6 '- DIM cnt, nRow, RetVal RetVal = MSGBOX("Are you sure you want to delete this line?" , "Please confirm", MB_ICONWARNING|MB_YESNO) IF RetVal = IDYES THEN nRow = SendMessage(hGrid1, GM_GETCURROW,0 ,0) SendMessage(hGrid1, GM_DELROW, nRow, 0) cnt = SendMessage(hGrid1, GM_GETROWCOUNT, 0, 0) IF nRow = 0 THEN SendMessage(hGrid1, GM_SETCURROW, nRow, 0) ELSE SendMessage(hGrid1, GM_SETCURROW, nRow-1, 0) END IF END IF END SELECT END SUB Function AddColumn(hGrid AS HWND, hdrtext$, coltype) As Long Dim col As COLUMN Dim lRet As Long Dim sz AS SIZE PTR sz = GETTEXTSIZE(hdrtext$) col.colwt = sz->cx + 20 col.lpszhdrtext = hdrtext$ col.halign = ALIGN_LEFT col.calign = ALIGN_LEFT col.ctype = coltype col.ctextmax = 2048 col.lpszformat = 0 col.himl = 0 col.hdrflag = 0 Ra_AddCol(hGrid,col) End Function SUB RunForm() DIM yy AS DOUBLE DIM xx AS DOUBLE DIM pth$, CText$, fil$ DIm rowcnt, i pth$ = CURDIR$ + "\" + "PO_Template.xls" print pth$ set xl = CreateObject("Excel.Application") xl.workbooks.add xl.visible = TRUE yy = 376.5 : xx = 1.5 DIM oWB AS Object Set oWB = xl.Workbooks.Open(pth$) xl.ActiveSheet.Cells(13,1).Value = Vend[G_pos].szName$ xl.ActiveSheet.Cells(14,1).Value = Vend[G_pos].szAdd1$ xl.ActiveSheet.Cells(15,1).Value = Vend[G_pos].szAdd2$ CText$ = JOIN$(5, Vend[G_pos].szCity$," ",Vend[G_pos].szState$,", ",Vend[G_pos].szZip$) xl.ActiveSheet.Cells(16,1).Value = CText$ xl.ActiveSheet.Cells(17,1).Value = Vend[G_pos].szCountry$ xl.ActiveSheet.Cells(18,2).Value = Vend[G_pos].szContact$ xl.ActiveSheet.Cells(18,5).Value = Vend[G_pos].szExt$ xl.ActiveSheet.Cells(19,2).Value = Vend[G_pos].szPhone$ xl.ActiveSheet.Cells(20,2).Value = Vend[G_pos].szFax$ CText$ = BCX_GET_TEXT$(hPOhWnd) DIM svDir$ svDir$ = JOIN$(6, CURDIR$, "\", Vend[G_pos].szName$, "_PO", CText$, ".xls") xl.ActiveSheet.Cells(7,8).Value = CText$ xl.ActiveSheet.Cells(8,8).Value = G_Time$ DIM crow, ccol DIM Buffer$, mult$ crow = SendMessage(hGrid1, GM_GETCURROW, 0, 0) ccol = SendMessage(hGrid1, GM_GETCURCOL, 0, 0) SendMessage(hGrid1, GM_GETCELLDATA, MAKEWPARAM(ccol,crow), Buffer$) DIM cnt, rnum, sb, eb cnt = 29 : yy = 351 rowcnt = SendMessage(hGrid1,GM_GETROWCOUNT,0,0) FOR i = 1 to rowcnt yy = yy + 25.5 xl.ActiveSheet.Cells(cnt,6).Value = "each" mult$ = "=PRODUCT(G" + TRIM$(STR$(cnt)) + ":H" + TRIM$(STR$(cnt)) + ")" xl.ActiveSheet.Cells(cnt,10).Value = mult$ IF cnt < 45 THEN xl.ActiveSheet.Shapes.AddLine( 1.5, yy, 505, yy).Line.DashStyle = 3 END IF cnt = cnt + 2 sb = 56 : eb = 63 IF cnt > 45 THEN 'no line and move the border to the next page IF cnt > 55 THEN DrawBorder(sb, sb+8) 'test ELSE sb = 62 : eb = 69 DrawBorder(sb, eb) 'test xl.ActiveSheet.PageSetup.PrintArea = "$A$1:$J$108" xl.ActiveSheet.Cells(sb+1,8).Font.Bold = TRUE xl.ActiveSheet.Cells(sb+1,8).Value = "Subtotal" xl.ActiveSheet.Cells(sb+2,8).Font.Bold = TRUE xl.ActiveSheet.Cells(sb+2,8).Value = "Tax1" xl.ActiveSheet.Cells(sb+3,8).Font.Bold = TRUE xl.ActiveSheet.Cells(sb+3,8).Value = "Tax2" xl.ActiveSheet.Cells(sb+4,8).Font.Bold = TRUE xl.ActiveSheet.Cells(sb+4,8).Value = "S + H" xl.ActiveSheet.Cells(sb+6,8).Font.Bold = TRUE xl.ActiveSheet.Cells(sb+6,8).Value = "Total" xl.ActiveSheet.Cells(sb+4,1).Font.Bold = TRUE xl.ActiveSheet.Cells(sb+4,1).Value = "Notes" xl.ActiveSheet.Cells(sb+1,10).Value = "=SUM(J29:J56)" xl.ActiveSheet.Cells(sb+2,10).Value = "=PRODUCT(J63,I64)" DIM pcent$ pcent$ = "I" + TRIM$(STR$(sb+2)) xl.Range(pcent$).Select xl.Selection.Style = "Percent" pcent$ = "I" + TRIM$(STR$(sb+3)) xl.Range(pcent$).Select xl.Selection.Style = "Percent" END IF NEXT xl.ActiveSheet.Shapes.AddLine(288, 841.5, 506.25, 841.5) xl.Selection.ShapeRange.Line.Weight = 2.25 xl.Selection.ShapeRange.Line.Visible = msoTrue xl.Selection.ShapeRange.Line.Style = msoLineSingle xl.activeworkbook.SaveAs svDir$ xl.activeworkbook.saved = true xl.UserControl = true 'xl.quit set oWB = Nothing set xl = Nothing END SUB ' ' Dim oe As Object = CreateObject("Excel.Application") ' Dim ow As Object = oe.workbooks.open("excelfile.xls") ' Dim r As Object ' r = ow.worksheets(1).Cells.find(What:="b") ' ' If Not r Is Nothing Then ' MsgBox(r.address) ' End If ' oe.quit() SUB DrawBorder(sBegin, sEnd) DIM szStart$, szEnd$, szAll$ szStart$ = "F" + TRIM$(STR$(sBegin)) : szEnd$ = "J" + TRIM$(STR$(sEnd)) szAll$ = szStart$ + ":" + szEnd$ xl.Range(szAll$).Select xl.Range.Selection.Borders(xlDiagonalDown).LineStyle = xlNone xl.Range.Selection.Borders(xlDiagonalUp).LineStyle = xlNone With xl.Range.Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With xl.Range.Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With xl.Range.Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With xl.Range.Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With xl.Range.Selection.Borders(xlInsideVertical).LineStyle = xlNone xl.Range.Selection.Borders(xlInsideHorizontal).LineStyle = xlNone xl.Range("A29").Select END SUB SUB WriteForm() dim pth$, CText$, fil$ dim rowcnt fil$ = Vend[G_pos].szName$ + ".vbs" IF *fil$ THEN OPEN fil$ FOR OUTPUT AS FP1 FPRINT FP1, " DIM xl" FPRINT FP1, " Set xl = CreateObject(", DQ$,"Excel.Application",DQ$,")" FPRINT FP1, " xl.Visible = True" FPRINT FP1, " xl.Workbooks.Add" pth$ = CURDIR$ + "\" + "PO_Template.xls" FPRINT FP1, " DIM oWB" FPRINT FP1, " Set oWB = xl.Workbooks.Open(",DQ$,pth$,DQ$,")" FPRINT FP1, " xl.ActiveSheet.Cells(13,1).Value = ",ENC$(Vend[G_pos].szName$) FPRINT FP1, " xl.ActiveSheet.Cells(14,1).Value = ",ENC$(Vend[G_pos].szAdd1$) FPRINT FP1, " xl.ActiveSheet.Cells(15,1).Value = ",ENC$(Vend[G_pos].szAdd2$) CText$ = JOIN$(5, Vend[G_pos].szCity$," ",Vend[G_pos].szState$,", ",Vend[G_pos].szZip$) FPRINT FP1, " xl.ActiveSheet.Cells(16,1).Value = ",ENC$(CText$) FPRINT FP1, " xl.ActiveSheet.Cells(17,1).Value = ",ENC$(Vend[G_pos].szCountry$) FPRINT FP1, " xl.ActiveSheet.Cells(18,2).Value = ",ENC$(Vend[G_pos].szContact$) FPRINT FP1, " xl.ActiveSheet.Cells(18,5).Value = ",ENC$(Vend[G_pos].szExt$) FPRINT FP1, " xl.ActiveSheet.Cells(19,2).Value = ",ENC$(Vend[G_pos].szPhone$) FPRINT FP1, " xl.ActiveSheet.Cells(20,2).Value = ",ENC$(Vend[G_pos].szFax$) CText$ = BCX_GET_TEXT$(hPOhWnd) DIM svDir$ svDir$ = JOIN$(6, CURDIR$, "\", Vend[G_pos].szName$, "_PO", CText$, ".xls") FPRINT FP1, " xl.ActiveSheet.Cells(7,8).Value = ",CText$ FPRINT FP1, " xl.ActiveSheet.Cells(8,8).Value = ",ENC$(G_Time$) DIM crow, ccol DIM Buffer$ crow = SendMessage(hGrid1, GM_GETCURROW, 0, 0) ccol = SendMessage(hGrid1, GM_GETCURCOL, 0, 0) SendMessage(hGrid1, GM_GETCELLDATA, MAKEWPARAM(ccol,crow), Buffer$) FPRINT FP1, " DIM yy" FPRINT FP1, " DIM i" FPRINT FP1, " DIM cnt" FPRINT FP1, " cnt = 31" FPRINT FP1, " yy = 376.5" rowcnt = SendMessage(hGrid1,GM_GETROWCOUNT,0,0) FPRINT FP1, " FOR i = 1 to ", rowcnt-1 FPRINT FP1, " yy = yy + 25.5" FPRINT FP1, " xl.ActiveSheet.Cells(cnt,6).Value = ",DQ$,"each",DQ$ FPRINT FP1, " cnt = cnt + 2" FPRINT FP1, " With xl.ActiveSheet.Shapes.AddLine( 1.5, yy, 505, yy).Line" FPRINT FP1, " .DashStyle = 3" FPRINT FP1, " End With" FPRINT FP1, " NEXT" FPRINT FP1, " xl.activeworkbook.SaveAs ", ENC$(svDir$) FPRINT FP1, " xl.activeworkbook.saved = true" FPRINT FP1, " xl.UserControl = true" FPRINT FP1, " set xl = Nothing" CLOSE FP1 END IF DIM BUFFER$ * LOF (fil$) BUFFER$ = LOADFILE$(fil$) VBS_START VBS_RUN_SCRIPT(BUFFER$) VBS_STOP IF EXIST(fil$) THEN KILL fil$ END SUB