Professional Documents
Culture Documents
loMerge
= m.loWord.ActiveDocument.MailMerge
loMerge.openDataSource(m.tcXLSFile,,,,,,,,,,,'Entire
Spreadsheet',m.lcSheet)
endfunc
In a nutshell, this explains how I automate word 2003, attach an excel 2003
data source, and complete a print merge without user or programmer
intervention. cs
This solution has a story to go along with it: I have a web site where users
keep track of participants in a medical protocol. Users produce mail merges
based results of recent treatement. The web site is on a very secure machine
where I am not allowed by network authority to install word or excel, though I
can place both file types on the secure server. However, I can access the data
on the secure server from a machine that has the complete Office 2003 suite.
Provided within the web application is a form where users can request a
particular mail merge. The form adds a record to a queue, a fox pro table. A
listner program, running on a computer with a less restrictive installation
requirement, periodically checks for new print merge request in the queue.
When a new request is discovered, the listner launches the automated print
merge routine below to produce the document, and then updates the queue to
reflect that the merge has been completed.
Complications: I needed a way to merge a Word 2003 with an Excel 2003
spreadsheet in an unattended mode, and I could not seem to avoid dialogue
boxes. Though I considered using a different file format for my data source, I
stubbornly felt I wanted to utilize the Office 2003 suite as it should work. I read
the approachs in "Microsoft Office Automation with Visual FoxPro" and also one
in the "1001 things you Wanted to Know About Visual FoxPro" I felt those
solutions were utilizing the power MS had built (clunkily) into the office suite.
So here are the things I did to set up my word templates.
1. Created a normal word document with the merge fields embedded
Created sample excel data containing fields I needed for merging with word
Created the document
Used the word interface to attach the excel data to the word document
Inserted all merge fields needed into the word document
Converted the word document to a NORMAL word document. The merge fields
remain, but if printed will print as literals, not as merged data.
Here is what Word 2003 says about converting a merge template document into
a normal document:
2. Set my macro security lower than I like and allowed access to VBA Project
(from word look under options security follow the macro security button edit
both tabs in the "Security" dialogue that pops up enable access to the VBA
project)
3. Wrote a routine to attach a data source to a word document on the fly from
Fox and then to do the print merge.
4 Wrote a routine to check for consistency between the data source attached
and the word document. Using my methodology you can have some
inconsistencies that are show stoppers if you do not do this step. See: Data
Source Consistency Check
My methods are not without drawbacks. We should not have to use automation
to add a macro to attach a data source for the soul purpose of avoiding a
dialogue during the print merge. I did not find an easier way and would
welcome one. I was completely happy to find a way that worked at all! I also do
not like the requirement of needing to trust access to the VBA Project, however
did not find a way around it. In my particular situation that is not an issue, but
for many people that would be a show stopper.
?cs
*
------------------------------------------------------------------------------------* Print Merge
*
------------------------------------------------------------------------------------function PrintMerge( )
*
------------------------------------------------------------------------------------* In production these parameters are passed in from
a parameter object, spelled
* out here for clarification
*
-------------------------------------------------------------------------------------
llContinue = .t.
lcTempFolder
lcTemplateDoc
= [c:\template\MergeTemplate] &&
actual word document merge template, keep templates in
a seperate folder
lcTemplateCopy
= [c:\temp\TemplateCopy] && copy
of the word document merge tempate
lcTempMacro
= [c:\temp\AttachSourceMacro.txt]
&& macro to attach source data
lcMergeData
source data
= [c:\temp\ExcelData.xls] &&
lcMergedDoc
= [c:\result\MergedDocument.doc]
&& output document in result folder
*
-------------------------------------------------------------------------------------------------------------* Checking for files omitted for simplicity
*
-------------------------------------------------------------------------------------------------------------this.createMacroTextFile(m.lcTempMacro,
m.lcMergeData )
*
------------------------------------------------------------------------------------* work with a copy of the template word document,
that way if things go
* bad you really haven't hurt anything
copy file(m.lcTemplateDoc + [.doc]) to
(m.lcTemplateCopy + [.doc])
*
------------------------------------------------------------------------------------* Error trapping code not included here, but you DO
want it since
* it is very easy for things go wrong at any of
these steps
*
-------------------------------------------------------------------------------------
*
------------------------------------------------------------------------------------* Open word automation object
loWord = createobject([word.application])
*
------------------------------------------------------------------------------------* Open copy of template
loDocument =
m.loWord.Documents.open( m.lcTemplateCopy)
template copy
&& open
*
------------------------------------------------------------------------------------* Macro security and access to VBA Project must be
enabled for this step
* See word options security tab.
loDocument.VBProject.VBComponents("ThisDocument").Code
Module.AddFromFile(m.lcTempMacro)
*
------------------------------------------------------------------------------------* attaches the text subroutine in the text file to
the word document
loWord.run("AttachSource")
*
------------------------------------------------------------------------------------* at this stage I do have a routine for checking the
document validity I run
* prior to executing the merge, it can be found
under the wiki topic: Data Source Consistency Check
*
------------------------------------------------------------------------------------* perform the merge
loDocument.MailMerge.Execute
*
------------------------------------------------------------------------------------* save and close down merged document
loMergedDocument = m.loWord.ActiveDocument
&& Focus to the merged document
loMergedDocument.saveas( m.lcMergedDoc )
&& Save with the outputfile name
loMergedDocument.close(0) && close w/o prompt
*
------------------------------------------------------
*
------------------------------------------------------------------------------------* Release objects
*
------------------------------------------------------------------------------------loDocument = .null.
loMergedDocument = .null.
loWord.quit
loWord = .null.
release loWord
*
------------------------------------------------------------------------------------* Throw away copy of template document and template
macro
*
------------------------------------------------------------------------------------delete file (m.lcTemplateCopy + [.doc])
delete file (m.lcTempMacro)
endfunc
function createMacroTextFile(tcFile,tcSource)
*
------------------------------------------------------------------------------------* NOTE: the SQL statement parameter:
*
*
*
* The "$" is very important.
took me a long time to figure
= alltrim(tcSource)
lcSourceFile = juststem(m.lcSource)
lcSourcePath = justpath(m.lcSource)
lcSource
+ [.xls]
*
------------------------------------------------------------------------------------* The following code puts creates a variable
containing the text of a VBA subroutine
*
-------------------------------------------------------------------------------------
ActiveDocument.MailMerge.MainDocumentType =
wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"<>" _
, ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="",
WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User
ID=Admin;Data Source=<>;Mode=Read;Extended
Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System
database="""";Jet OLEDB:Registry Path="""";Jet O" _
, SQLStatement:="SELECT * FROM `<>$`",
SQLStatement1:="" _
, SubType:=wdMergeSubTypeAccess
End Sub
ENDTEXT
debugout m.lcMacroText
endfunc
***********************+++
FoxPro Fundamentals
For Better
Functionality, Pave
Working interactively
If you haven't done much with OLE, it's a good idea to
experiment a bit from the Command window before you
begin designing forms. These interactive techniques will
also serve you well for troubleshooting OLE problems. If
something doesn't work in a form, try opening the table in
Browse and see if you can accomplish the same task
interactively.
As is the case with Memo fields, the data in General fields
isn't visible in the default Browse or Edit screen. Visual
FoxPro displays the field as "gen" if it's empty, or "Gen" if it
contains data. To view or edit the contents, tab into the
General field and press Ctrl+Home, or double-click in the
field. These commands open an editing window like the one
shown in figure 1. Usually, you'll want to leave this window
open, so you can always see the contents of the General
field in the current record as you move through the table.
OLE objects that have no meaningful static representation
(such as sound or video recordings) are displayed as the
standard Windows icon for the server program.
All the options for creating and manipulating OLE objects
are on the Edit menu. If the General field that has the
focus is empty, only Insert Object is enabled; choosing this
option calls up the dialog shown in figure 2, which lets you
embed an OLE object. (You can't create a linked object this
way; you have to use the Windows Clipboard, as I'll explain
shortly.)
Building forms
OK, I know you're ready to close that Browse window and
start building a form. However, all the foregoing material
wasn't just a learning exercise in interactive FoxPro. If
you're willing to use the same commands to create and edit
OLE objects in forms, building the forms is trivial: Simply
create a bound OLE control to display the General field that
stores the OLE data.
You can place unbound OLE controlsobjects not stored in
a table, such as graphs or pictureson a Visual FoxPro
form, but you use the unbound OLE Container tool to do
so.
Setting
Description
0 - Manual
1 - GotFocus
focus.
2 - DoubleClick
APPENDGENERAL<fieldname>FROM<filename>
By default, the APPEND GENERAL command creates an
embedded object; to create a link instead, add the keyword
LINK to the command.
the object.
The DoVerb method takes one numeric parameter, which
specifies which of several activation methods you want to
use. The ones you'll use most often are shown in table 2.
Table 2: DOVERB METHOD PARAMETERSSpecifies the
activation method you want to use.
Method
Description
-1
-2
For example, you can open the server application for the
oleContract object with:
THISFORM.oleContract.DoVerb(1)
The form in figure 6 uses this command in the Click
method for the Edit button.
The Delete button uses the BLANK FIELD command to
empty the Contract field, then disable the Edit button
(because there's nothing to edit). If you haven't
encountered the BLANK FIELD command before, note that
this command can be used for any type of field (not just
General fields), but it's the only way to delete the contents
of a General field. Here's the complete command sequence:
BLANKFIELDContract
THISFORM.oleContract.Refresh()
THISFORM.cmdEdit.Enabled=.F.
Finally, the New button lets the user insert an existing
document into the Contract field or create a new document.
The best way to encourage the user to do the right thing is
to display an Open File dialog that includes only files of the
specified typein this case, Word documents:
LOCALlcFileName
lcFileName=GETFILE("DOC","Choosea
document:",;
"Open",1)
IFEMPTY(lcFileName)
RETURN
ENDIF
IFUPPER(RIGHT(lcFileName,3))<>"DOC"
=MESSAGEBOX("YoumustchooseaWorddocument
file",;
MSGOKONLY+MSGEXCLAMATION,
C_APPNAME)
RETURN
ENDIF
IF"UNTITLED"$UPPER(lcFileName)
APPENDGENERALMaillist.ContractCLASS
Word.Document.6
ELSE
APPENDGENERALMaillist.ContractFROM
(lcFileName)
ENDIF
THISFORM.cmdEdit.Enabled=.T.
THISFORM.oleContract.Refresh()
THISFORM.oleContract.DoVerb(1)
This routine calls the GETFILE() function to display the
Open File dialog like the one shown in figure 7, which
includes only files with the extension .DOC. (If you're not
familiar with this function, I covered it in the February 1995
issue.) GETFILE() returns the name of the file selected
from the dialog, or an empty string if the user exits by
clicking on the Cancel button.
The Edit routine performs some basic error-checking on the
file selected by the user. If the extension isn't .DOC, it
displays an error message and returns the user to the form
to try again. This isn't an entirely satisfactory solution,
because a Word file could have an extension other than
.DOC, and files created by other programs could have this
extension. You might prefer to simply ask the user for
confirmation, rather than rejecting the selected file
unequivocally.
What's next?
There's one more layer of power and complexity: OLE
Automation, which lets you write programs that control an
OLE server application using its own command language
(Word Basic, Visual Basic for Applications, and so on). With
this technique, you can harness all the capabilities of the
server application behind the scenes, with no user
intervention.
For example, you could construct a Word document that
performs a mail merge and prints letters and envelopes, all
done from a Visual FoxPro program. Of course, this
requires some familiarity with the command language of
the server application and, nowadays, an understanding of
its object model, and that's beyond the scope of this
column.
*Before begin running the code achieve the downnload of tinyMCE 3.5.11.its free richtext web editor
for personal use.
Click on code to select [then copy] -click outside to deselect
*1*
Local m.yrep
m.yrep=Addbs(Justpath(Sys(16,1)))
Set Defa To (yrep)
Local m.x,m.myvar
m.xx=Int(Val(Inputbox("Skin 1(default),2(O2k7
skin),3(silver),4(black)","","1")))
If Empty(m.xx)
Return .F.
Endi
If !Inlist(m.xx,1,2,3,4)
m.x=1
Endi
Do Case
Case m.xx=1
TEXT to m.myvar noshow
// Default skin
tinyMCE.init({
// General options
mode : "exact",
elements : "ytextarea",
theme : "advanced",
plugins :
"autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlin
k,emotions,iespell,insertdatetime,preview,media,searchreplace,print,co
ntextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonb
reaking,xhtmlxtras,template,inlinepopups,autosave",
// Theme options
theme_advanced_buttons1 :
"save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,
justifycenter,justifyright,justifyfull,styleselect,formatselect,fontse
lect,fontsizeselect",
theme_advanced_buttons2 :
"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist
,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cl
eanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor"
,
theme_advanced_buttons3 :
"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotion
s,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 :
"insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abb
r,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak
,restoredraft",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
save_enablewhendirty: true,
Case m.xx=2
TEXT to m.myvar noshow
// O2k7 skin
tinyMCE.init({
// General options
mode : "exact",
elements : "ytextarea",
theme : "advanced",
skin : "o2k7",
plugins :
"lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotion
s,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu
,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,x
htmlxtras,template,inlinepopups,autosave",
// Theme options
theme_advanced_buttons1 :
"save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,
justifycenter,justifyright,justifyfull,styleselect,formatselect,fontse
lect,fontsizeselect",
theme_advanced_buttons2 :
"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist
,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cl
eanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor"
,
theme_advanced_buttons3 :
"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotion
s,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 :
"insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abb
r,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak
,restoredraft",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
save_enablewhendirty: true,
Case m.xx=3
TEXT to m.myvar noshow
// O2k7 skin (silver)
tinyMCE.init({
// General options
mode : "exact",
elements : "ytextarea",
theme : "advanced",
skin : "o2k7",
skin_variant : "silver",
plugins :
"lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotion
s,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu
,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,x
htmlxtras,template,inlinepopups,autosave",
// Theme options
theme_advanced_buttons1 :
"save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,
justifycenter,justifyright,justifyfull,styleselect,formatselect,fontse
lect,fontsizeselect",
theme_advanced_buttons2 :
"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist
,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cl
eanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor"
,
theme_advanced_buttons3 :
"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotion
s,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 :
"insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abb
r,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak
,restoredraft",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
save_enablewhendirty: true,
});
ENDTEXT
Case m.xx=4
TEXT to m.myvar noshow
// O2k7 skin (silver)
tinyMCE.init({
// General options
mode : "exact",
elements : "ytextarea",
theme : "advanced",
skin : "o2k7",
skin_variant : "black",
plugins :
"lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotion
s,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu
,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,x
htmlxtras,template,inlinepopups,autosave",
// Theme options
theme_advanced_buttons1 :
"save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,
justifycenter,justifyright,justifyfull,styleselect,formatselect,fontse
lect,fontsizeselect",
theme_advanced_buttons2 :
"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist
,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cl
eanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor"
,
theme_advanced_buttons3 :
"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotion
s,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 :
"insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abb
r,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak
,restoredraft",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
save_enablewhendirty: true,
content_css : "css/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
ENDTEXT
Endcase
Local m.my
TEXT to m.my textmerge noshow
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>full Richtext tinyMCE with Skins</title>
<!-- TinyMCE -->
<script type="text/javascript"
src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
<<m.myvar>>
</script>
<!-- /TinyMCE -->
</head>
<body>
<form method="post" action="http://tinymce.moxiecode.com/dump.php?
example=true"
<div>
<textarea id="ytextarea" name="elm1" rows="36" cols="80"
style="width:100%"> type your texts here
</textarea><br />
</div>
<!-<input type="submit" name="save" value="Submit" /> -->
<input type="reset" name="reset" value="Reset" />
</form>
</body>
ENDTEXT
Set Safe Off
Local m.lcdest
m.lcdest=m.yrep+"ytest.html"
Strtofile(m.my,m.lcdest)
Declare Integer BringWindowToTop In user32 Integer
Publi apie
apie=Newobject("internetexplorer.application")
With apie
.menubar=0
.Toolbar=0
.StatusBar=0
.Resizable=1
.Width=900
.Height=650
.Top=(Sysmetric(2)-.Height)/2
.Left=(Sysmetric(1)-.Width)/2
.Navigate(m.lcdest)
BringWindowToTop(.HWnd)
.Visible=.T.
Endwith
retu
*i disabled the save button in the script for 4 skins.
*can try with ie browser embed on vfp form also.
this is the full app.can restrict in code the buttons shown as customization.....
Click on code to select [then copy] -click outside to deselect
*2*
*promptly said, promptly made!
theme_advanced_buttons3 :
"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emoti
ons,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 :
"insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,a
bbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pageb
reak,restoredraft",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location :
"bottom",
theme_advanced_resizing : true,
save_enablewhendirty: true,
mode : "exact",
elements : "ytextarea",
theme : "advanced",
skin : "o2k7",
plugins :
"lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emoti
ons,iespell,insertdatetime,preview,media,searchreplace,print,context
menu,paste,directionality,fullscreen,noneditable,visualchars,nonbrea
king,xhtmlxtras,template,inlinepopups,autosave",
// Theme options
theme_advanced_buttons1 :
"save,newdocument,|,bold,italic,underline,strikethrough,|,justifylef
t,justifycenter,justifyright,justifyfull,styleselect,formatselect,fo
ntselect,fontsizeselect",
theme_advanced_buttons2 :
"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numli
st,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,imag
e,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,back
color",
theme_advanced_buttons3 :
"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emoti
ons,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 :
"insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,a
bbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pageb
reak,restoredraft",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location :
"bottom",
theme_advanced_resizing : true,
save_enablewhendirty: true,
// Example content CSS (should be your
site CSS)
content_css : "css/content.css",
// Drop lists for
link/image/media/template dialogs
template_external_list_url :
"lists/template_list.js",
external_link_list_url :
"lists/link_list.js",
external_image_list_url :
"lists/image_list.js",
media_external_list_url :
"lists/media_list.js",
// Replace values for the template
plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
ENDTEXT
Case m.xx=3
TEXT to m.myvar noshow
// O2k7 skin (silver)
tinyMCE.init({
// General options
mode : "exact",
elements : "ytextarea",
theme : "advanced",
skin : "o2k7",
skin_variant : "silver",
plugins :
"lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emoti
ons,iespell,insertdatetime,preview,media,searchreplace,print,context
menu,paste,directionality,fullscreen,noneditable,visualchars,nonbrea
king,xhtmlxtras,template,inlinepopups,autosave",
// Theme options
theme_advanced_buttons1 :
"save,newdocument,|,bold,italic,underline,strikethrough,|,justifylef
t,justifycenter,justifyright,justifyfull,styleselect,formatselect,fo
ntselect,fontsizeselect",
theme_advanced_buttons2 :
"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numli
st,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,imag
e,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,back
color",
theme_advanced_buttons3 :
"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emoti
ons,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 :
"insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,a
bbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pageb
reak,restoredraft",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location :
"bottom",
theme_advanced_resizing : true,
save_enablewhendirty: true,
// Example content CSS (should be your
site CSS)
content_css : "css/content.css",
// Drop lists for
link/image/media/template dialogs
template_external_list_url :
"lists/template_list.js",
external_link_list_url :
"lists/link_list.js",
external_image_list_url :
"lists/image_list.js",
media_external_list_url :
"lists/media_list.js",
// Replace values for the template
plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
ENDTEXT
Case m.xx=4
TEXT to m.myvar noshow
// O2k7 skin (silver)
tinyMCE.init({
// General options
mode : "exact",
elements : "ytextarea",
theme : "advanced",
skin : "o2k7",
skin_variant : "black",
plugins :
"lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emoti
ons,iespell,insertdatetime,preview,media,searchreplace,print,context
menu,paste,directionality,fullscreen,noneditable,visualchars,nonbrea
king,xhtmlxtras,template,inlinepopups,autosave",
// Theme options
theme_advanced_buttons1 :
"save,newdocument,|,bold,italic,underline,strikethrough,|,justifylef
t,justifycenter,justifyright,justifyfull,styleselect,formatselect,fo
ntselect,fontsizeselect",
theme_advanced_buttons2 :
"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numli
st,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,imag
e,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,back
color",
theme_advanced_buttons3 :
"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emoti
ons,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 :
"insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,a
bbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pageb
reak,restoredraft",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location :
"bottom",
theme_advanced_resizing : true,
save_enablewhendirty: true,
// Example content CSS (should be your
site CSS)
content_css : "css/content.css",
// Drop lists for
link/image/media/template dialogs
template_external_list_url :
"lists/template_list.js",
external_link_list_url :
"lists/link_list.js",
external_image_list_url :
"lists/image_list.js",
media_external_list_url :
"lists/media_list.js",
// Replace values for the template
plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
ENDTEXT
Endcase
Local m.my
TEXT to m.my textmerge noshow
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>full Richtext tinyMCE with Skins</title>
<!-- TinyMCE -->
<script type="text/javascript"
src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
<<m.myvar>>
</script>
<!-- /TinyMCE -->
</head>
<body>
<form method="post"
action="http://tinymce.moxiecode.com/dump.php?example=true"
<div>
<textarea id="ytextarea" name="elm1" rows="30"
cols="80" style="width:100%"> type your texts here
</textarea><br />
</div>
<!-<input type="submit" name="save" value="Submit"
/> -->
<input type="reset" name="reset"
value="Reset" />
</form>
</body>
ENDTEXT
Set Safe Off
Local m.lcdest
m.lcdest=m.yrep+"ytest.html"
Strtofile(m.my,m.lcdest)
Thisform.obrowser.Navigate(m.lcdest)
Endproc
Procedure Init
Publi m.yrep
m.yrep=Addbs(Justpath(Sys(16,1)))
Set Defa To (yrep)
Thisform.ybuild()
Endproc
Procedure Destroy
Erase Addbs(Sys(2023)+"ytest.html"
Clea Events
Endproc
Procedure obrowser.Init
This.silent=.T.
Endproc
Procedure combo1.Click
Thisform.ybuild()
Endproc
Procedure combo1.Init
With This
.AddItem("Skin
.AddItem("skin
.AddItem("skin
.AddItem("skin
.ListIndex=1
.Value=1
.Style=2
Endwith
Endproc
Enddefine
*
*-- EndDefine: ytinyMCE
1(default)")
2 (O2k7 )")
3(silver)")
4(black)")
*3*
Local m.myvar
TEXT to m.myvar
noshow
<!DOCTYPE html>
<html>
<head>
<title> A basic tinyMCE richtext editor</title>
<script
src="http://tinymce.cachefly.net/4.3/tinymce.min.js"></script>
<script>tinymce.init({ selector:'textarea' });</script>
</head>
<body>
<textarea rows="15" cols="80" style="width:100%">Easy (and
free!) </textarea>
</body>
</html>
ENDTEXT
Set Safe Off
Local m.lcdest
m.lcdest=Addbs(Sys(2023))+"ytest.html"
Strtofile(m.myvar,m.lcdest)
apie=Newobject("internetexplorer.application")
With apie
.menubar=0
.Toolbar=0
.StatusBar=0
.Resizable=1
.Width=800
.Height=400
.Top=(Sysmetric(2)-.Height)/2
.Left=(Sysmetric(1)-.Width)/2
.Navigate(m.lcdest)
BringWindowToTop(.HWnd)
.Visible=.T.
Endwith
Grabbing cool web Apps with visual foxpro - Visual Foxpro codes
http://yousfi.over-blog.com/2015/11/grabbing-cool-web-apps-from-visualfoxpro.html
see in this post :code *8* for the initial idea of the richtext editor tinyMCE.
After the start you can create a new database. A few sample customers
will be added automatically. Now you can add an order and to this order
add order items. The product templates for each order item can be
selected in a data based table. There are data entry forms to add new
customers, countries (to modify VAT) and products.
Multidemo Mainform
out. Since WPViewPDF demo was used, the printout of the PDF
includes a demo watermark.