›¥! °  '             €  TF  §T                             ÐD                       L    L   L    L    L    L    L   )L   ;L    ;L    ;L    ;L    CT   ST   ;L    ;L   =L   AL    AL    AL    AL    AL    AL    AL    AL   [L   kL  ' ’L    ’L    ’L  B ÔL  % ’L    L    ’L    ’L    ’L      $ %                                                                         
8  6 Q+E ADDRESS_BOOK (Sample address macro for WFW & Q+E)9  F< D        Requires:	Word for Windows, Q+E, ADD_BOOK.QEF, ADD_BOOK.DBF.Yƒ W 	Note:	A limited version of Q+E from Pioneer Software (1-800-876-3101) is bundled with]Ý [ 		Microsoft Excel 3.0, and was available separately for Excel 2.0 and 2.1.  In particular,I;G		the file QE.EXE is required and must be available on the user's path.a…_     Execution:	This macro performs a query against the address database file based on the textVçT		in the current input line.  This is similar in concept to the normal procedure forT>R		inserting glossary entries using the F3 keyboard shortcut method.  The letter(s)Z“X		in the input line are matched against the INDEX field in the address file.  This INDEXRîP		field has been designed as an acronym based on (for instance) the company name;A9		concatenated with the individual's name.  For instance:>}<			MS_KE = Microsoft, Kate Edson (WFW Section Leader on CIS)?¼=			MS_SW = Microsoft, Stuart Wiley (WinWord Developer's Desk)&ü$			KRP = Keith R. Pleas (the author)# b&`   Other:	If the user is interested in playing with the DDE interface to Q+E, try the following:7‰5		Insert "SYSITEMS: " + DDERequest$(chan, "SYSITEMS")3Á1		Insert "TOPICS: " + DDERequest$(chan, "TOPICS")5õ3		Insert "FORMATS: " + DDERequest$(chan, "FORMATS")3+1		Insert "STATUS: " + DDERequest$(chan, "STATUS")3_1		Insert "SOURCE: " + DDERequest$(chan, "SOURCE")5“3		Insert "SOURCES: " + DDERequest$(chan, "SOURCES")É $Ì"            Author:	Keith R. Pleasñ               Date:	06/02/91!                CIS:	72331,2150230        Internet:	kpleas@milton.u.washington.eduf		keithp@nwnexus.wa.com €g‚e This macro is an example of using Q+E to insert address lines into a WFW document from a standalone jêh dBase address file.  It is "freeware" and may be copied and modified freely.  Note: the author makes noiUg guarantees as to fitness of use, performance or execution, and the user is using it at their own risk.¿ gÃe The main program (Sub Main) is first, followed (alphabetically) by Functions then other Subroutines.+ `/^ This macro has been designed to work with a Q+E Query File (ADD_BOOK.QEF), and runs against al�j single dBase IV file (or table) containting name, address, and phone information.  If these files are notÕýÓ included, they can easily be recreated by the user using Q+E interactively.  It is important that the actual ' Fields in the .QEF file be properly referenced in the F??????? variables listed below since the WFWbÓ	` DDERequest$ command uses the "RxCx" notation.  The ADD_BOOK.QEF file has the following fields: 6
 :
    #	Field Name	Type		LengthGZ
E  -------------------------------------------------------------------¢
     1	INDEX		Character	8¾
     2	L_NAME	Character	20Û
     3	F_NAME	Character	20ø
     4	TITLE		Character	20     5	COMPANY	Character	303     6	ADDRESS1	Character	30R     7	ADDRESS2	Character	25q     8	CITY		Character	20�     9	STATE		Character	2©     10	ZIP		Character	10Å     11	COUNTRY	Character	20ä     12	AREA_CODE	Character	3     13	H_PHONE	Character	8"     14	W_PHONE	Character	8@     15	FAX		Character	8[     16	NOTES		Memo	0r/0curdir$			 Holds the current directory3¦/0qfile$			  Holds the Query (.QEF) filename7Ý/0dbfile$			# Holds the Database (.DBF) filename%/0chan				 DDE channel to Q+EJA/0matchnum			5 Number of INDEX matches for user-entered lookup textE�/0Index$			2 Holds the partial INDEX to query & returned INDEX"Ø/0N$				 Newline character þ/0Q$				 Quote character-"/0S$				 Separator used in Dialog BoxS/0T$				 Tab character u=w/0FIndex$			) Column reference to database INDEX field>¸/0FLName$			* Column reference to database L_NAME field>ú/0FFName$			* Column reference to database F_NAME fieldA</0	FCompany$			+ Column reference to database COMPANY fieldC�/0
FAddress1$			, Column reference to database ADDRESS1 fieldCÈ/0
FAddress2$			, Column reference to database ADDRESS2 field;/0FCity$			( Column reference to database CITY field=N/0FState$			) Column reference to database STATE field9�/0FZip$			' Column reference to database ZIP field ÌÎMAINBØ   N$j 				% Set references to special characters   Q$j" &   S$, 4   T$j	 E   GJ   FIndex$C1			, Set references to database fields / columns�   FLName$C2    FFName$C3³   	FCompany$C5È   
FAddress1$C6Þ   
FAddress2$C7ô   FCity$C8   FState$C9   FZip$C10 +[-   
qeinitiate  *retmain	1 Initiate (or verify existing) DDE channel to Q+E^ˆ   qfile$wqequeryfile 	1 Check to see if an Address file has been definedCç   qfile$ setquery		 If not, get it from a dialog.<)					3 NOTE: to change address file, delete Glossay entryBd   qeopen  *retmain		 Open the Query (.QEF) fileb¦   match    *retmain		8 Try for a single match; or select from multiple matches?					6 NOTE: text to match is to the LEFT of the cursor; the@C					7  	procedure is  similar to using the Glossary key (F3)R‚   pasterec  *retmain	* Replace the lookup value with the address
ÔretmainNÞ   chan  ¿ chan	, Termiantes the DDE channel (if established)3 <J>cd				< Change directory: this function is called from the setqueryQŒ   ,-*cderr			8   subroutine if the user enters something than a Query Uà   Xqfile$				=   (.QEF) file.  The macro then assumes that the user enteredW3   cd 					@   a valid directory path and tries to change to that directory.E„   *cdret				/   Valid entries may use the following formats:9Çcderr					(   	"..", "c:\windows\excel", "..\excel"ý   cd  cdret Q Chop$ddeval$				3 Chops the last two "characters" (carriage return &oq   Chop$lddeval$/ ddeval$j
  ,  line feed ASCII characters) from the value&×					  returned by DDERequest. match					    ,-*matcherra8   dbfile$wqequeryfile 		2 Gets the Q+E Query File (.QEF) from the Glossary lš   dbfile$ldbfile$/ dbfile$.QEFDBF	& and converts it for the .DBF filenameDÿ   = 					0 Grabs the user-entered text on the current lineTG   Index$  Q$r%Q$		# Convert to a literal search string¥˜   Select$  7[SQL.QUERY('SELECT INDEX, COMPANY, L_NAME, F_NAME FROM dbfile$ WHERE INDEX LIKE Index$' )]		 Build the SQL select statementP6   Å chanSelect$			0 Send the SQL select statement to Q+E to execute]‡   matchnum Ï chanNUMROWS+ Get back number of rows selected (matched)Bä   13matchnum				' Based on the number of number of rows:,)      3  					 0, quit and try again/S	           No match found!ADDRESS0 …	         match  6™      3 					  1, ready to proceed with insert'Í	         Cell$  R1FIndex$+ï	         Index$Ï chanCell$(	         Index$Chop$Index$-<	         Index$  Q$Index$Q$a	         match Ou      3 $2 					4 2 to 50 (or whatever, this can be easily modified),XÃ	         matchdlg  			3 run a dialog box to select a single match which...R            match  				0 ...fails (either cancelled or failed to select)e	          dt            Index$  Q$Index$Q$		. ...or succeeds (ready to proceed with insert)Í            match ä
          +ö      3 					 51+, inform the user.5#	           More than 50 matches!ADDRESS0 [	         match  	o   1~   *retmatch�matcherr›   match  ©retmatch´ ÂHÄmatchdlg				4 Function to produce a dialog box to select a singleU   ,-*matchdlgerr			6    record if from 2 to 50 records match the criteria.Uh   /arr$matchnum				2 Dimension an array for listbox to hold each match¶   #i $matchnum\Ð      R$Strip$ki				0 Convert the counter to a single alpha character[!       Cell$  RR$FIndex$			+ Build the "RxCx" designation for the INDEXBs       Index$Ï chanCell$		 Get the INDEX valueT³       Index$Chop$Index$			( Chop off the <CR> <LF> ASCII charactersDý       Cell$  RR$	FCompany$		 Repeat for COMPANY*8!      Company$Ï chanCell$-c!      Company$  Chop$Company$A†!      Cell$  RR$FFName$			 Repeat for FNAME(¾!      FName$Ï chanCell$%ç!      FName$Chop$FName$A"      Cell$  RR$FLName$			 Repeat for LNAME(="      LName$Ï chanCell$%f"      LName$Chop$LName$q„"      arr$i Index$S$Company$S$FName$ LName$ Concatenate array element3è"   &i									  Loop for next array element#   O? Â¦ k>#      g 
 X  	&Matches:kmatchnum   ' Static text with the number of matchesV¡#      L & �| arr$LB		" ListBox with the array of matches9ò#      e¬ 
 F  			 OK Button (required)I+$      fü 
 F  			% Cancel Button (optional but advised)	x$   ?2‡$   /dlg4 				 Dimension the dlg recordA¿$   dlgLB  					% Clear the default ListBox (LB) valueù$   >dlg(%   ?dlg					 Run the dialog box]6%   R$Strip$kdlgLB 			* Convert the value returned a single alpha9†%   Cell$RR$FIndex$			 (same as above);¹%   Index$Ï chanCell$		 (same as above)9ò%   Index$Chop$Index$			 (same as above)L!&   matchdlg 					/ Value returned by function to indicate successg&   *retmatchdlg|&matchdlgerrMŠ&   matchdlg  					0 Value returned by function to indicate an errorÑ&retmatchdlgß& í&Jï&pasterec				6 Ready to get the single address to insert in the doc.9='						/ Note: INDEX is known, so "=" instead of "LIKE"_u'  Select$  [SQL.QUERY('SELECT * FROM dbfile$ WHERE INDEX = Index$' )]OÐ'  Å chanSelect$			0 Send the SQL select statement to Q+E to execute? (  FName$Ï chanFFName$	 Get the FNAME valueP](  FName$Chop$FName$			( Chop off the <CR> <LF> ASCII characters<£(  LName$Ï chanFLName$	 Repeat for LNAME!Ý(  LName$Chop$LName$B÷(  Company$Ï chan	FCompany$	 Repeat for COMPANY%7)  Company$Chop$Company$EU)  	Address1$Ï chan
FAddress1$	 Repeat for ADDRESS1'˜)  	Address1$Chop$	Address1$E¸)  	Address2$Ï chan
FAddress2$	 Repeat for ADDRESS2'û)  	Address2$Chop$	Address2$:*  City$Ï chanFCity$		 Repeat for CITYS*  City$Chop$City$=k*  State$Ï chanFState$		 Repeat for STATE!¦*  State$Chop$State$7À*  Zip$Ï chanFZip$		 Repeat for ZIPõ*  Zip$Chop$Zip$=+  Close$  	[CLOSE()]				 Build the close literalQA+  Å chanClose$			3 Send the Close statement to Q+E to close the query “+8•+  Ù 					( Clear the look-up text before inserting^Ð+  4   FName$ LName$  N$		, N$ is used to keep address as one paragraphH&,    Company$!4 Company$N$	 Company if it existsKm,    	Address1$!4 	Address1$N$	 Address1 if it existsK·,    	Address2$!4 	Address2$N$	 Address2 if it exists,-  4 City$, State$  Zip$/-  *retpdlg?-	canceldlg
K-retpdlgU- c-He-
qeinitiate				2 Attempts to initiate a DDE conversation using theH±-   ,-*inierr				-     SYSTEM topic, which returns the channel Vü-   chan¾ QESYSTEM		.     number.  This channel number is used as aDT.   
qeinitiate 					%     parameter in other DDE commands.’.   *iniret	¢.inierr<«.     &Cannot Initiate a DDE Channel with Q+EQ+E0 ê.   
qeinitiate  	ý.iniret/ /F/qeopen					3 Tries to open the Query (.QEF) file chosen in the N`/   ,-*openerr				2    setquerydlg subroutine.  Normally, this shouldf±/   Å chan[OPEN('qfile$')]	7    not fail.  This filename is stored in the Glossary,;0   qeopen 					     and may have been  modified.O0   *retopen
`0openerr@j0      Q+E Cannot Open the Query File: qfile$Q+E0 ¬0   qeopen  
»0retopenÅ0 Ó0LÕ0Strip$row$				0 Strips of leading blank from the row identifieri!1   Strip$mrow$ row$ 		3    (holds the sign, which is not used) after being)€1					    converted from a numeric °1A²1setquery					, Subroutine to allow the user to specify the3ò1dodlg						!    Query (.QEF) file to be used.5"2   Setquerydlg					 Runs the query Dialog BoxVR2   
cancelflag *retmain		+ Checks for the Cancel Button being pressedf¨2      €mqfile$ .QEF	2 Did user select /enter a Query (.QEF) file, or...^3	         cd  *direrror			3 ...a valid directory specification.  If not: ERROR$m3	         Ÿ qequeryfile  D˜3	         *dodlg					' loop again to get an actual Query fileKÚ3       						7 Build the full patch specification for the .QEF file..($4	         / qfile$:  +M4            / qfile$\  :z4               qfile$lcurdir$ qfile$®4             3À4               qfile$curdir$\qfile$ð4            5	         5      #5   qfile$€qfile$V?5   Ÿ qequeryfileqfile$ 		, ..and put in in the Glossary for later use.—5   *retmain¨5direrror-³5     Invalid Query File NameQ+E0 ã5   *dodlgò5queryerrý5   setquery  
6retmain6 !6E#6setquerydlg					- Subroutine to handle the Dialog box to allowLg6getfiles						7    the user to select an individual Query (.QEF) file.°6   	filecount  					 cÉ6   P*.QEF   *gotcount	3 Skip the next section if their are no .QEF files, N.7   	filecount 					0   also sets the filespec for the Files$ command<v7   !P 				" Until we run out of .QEF files...Z¶7       	filecount	filecount 			-    ...increment the counter to dim the array	8   ">8gotcount					* Dim the array to the number of .QEF files@M8   /arr$	filecount 				    (arrays start at 0)\…8   	filecount  *gotfiles		1 Skip the next section if their are no .QEF files^á8   arr$  P*.QEF   			2 Initialize the array with the first .QEF filenameH89   #i $	filecount 			  For the remaining .QEF files...9{9      newfld$P				    ...get the filename±9      j  ¾9jloopÆ9      ji*doins_æ9      newfld$arr$j	      			. Sort the .QEF filenames in alphabetical order&?:	         #ki $j% /e:            arr$k arr$kˆ:	         &k ™:      arr$jnewfld$²:      *didinsÅ:      Ó:      jj ä:      *jloopö:doins þ:      arr$inewfld$	;didins
 ;   &i+;gotfiles6;   curdir$P.UP;   mcurdir$ \curdir$lcurdir$ curdir$  ;   O? ôœ NÅ;      g 
 ´  &Query File (or Directory):   Static textR<      M  ¯ | arr$FL		 Combo Box with .QEF filenames@\<      g¾ K `  Directory is:		 Static Text_˜<      g¾ Z Ô  curdir$			0 The current directory (full path specification)9ò<      eÞ  F  			 OK Button (required)N*=      fÞ   F  			* Cancel Button (not required, but advised)	|=   ?2‹=   /dlg4 				 Dimension the dlg record@Ã=   dlgFL 					% Clear the default ListBox (FL) valueþ=   >dlgG>   ,-*querydlgerr			( Primarily traps for Cancel Button press(]>   ?dlg					 Run the dialog boxH…>   qfile$dlgFL					' Set variable to FL field of dlg recordÆ>   
cancelflag  Ù>   *retsubé>querydlgerr÷>   
cancelflag 	
?retsub?


 			* Cancel Button (not required, but advised)	|=   ?2‹=   /dlg4 				 Dimension the dlg record@Ã=   dlgFL 					% Clear the default ListBox (FL) valueþ=   >dlgG>   ,-*querydlgerr			( Primarily traps for Cancel Button press(]>   ?dlg					 Run the dialog boxH…>   qfile$dlgFL					' Set variable to FL field of dlg recordÆ>   
cancelflag  Ù>€  ‚  RF  TF                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 €  ‚  PF  RF  TF  ûûûû                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
          Þ    ÔD   ÿÿÿÿ    ÔD  
ÿÿ      ÔD     €E ÿÿU ÿÿe ÿÿu ÿÿ      ÎD  ÔD  Ð!ÿÿ addressInsert ADDRESS using Q+E DDE"      à=Ð/    Ð  h    pó¤%«¶    W P                %       Tyler BennettKeith R. Pleas                                                                                                                                                                                                                                                                       ›¥! °                €O  ¡O  §T                  !                                    T    T   T    T    T    T    T   )T    )T    )T   7T   CT    CT   ST   )T    cT   eT    eT    eT    eT    eT    eT    eT    eT    eT    eT    eT    eT    eT    eT  B §T    eT    T    eT    eT    eT      ( )                                                                         C:\WINDOWS\EXCEL\ADD_BOOK.QEF

                                                                                               €O  ¡O                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         €O  ŸO  ¡O  ûû                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
          Þ    !    ÿÿÿÿ qequeryfile       !   €  €O  ¡O  $ ( €  €O  ¡O  % )  "      à=Ð/    Ð  h                                    