|
-
Mar 22nd, 2000, 03:55 AM
#2
Junior Member
Export 2 Word
U'll need 2 declare a word object and get the field values either from the form or the database(using a query) and use the code below to save it in doc (or rtf, or html or ascii text ) format.
Dim w As New Word.Application ' instance of MsWord
Dim strData as String
...' Query to retrieve values from the Database
...' or expressions to retrieve values from forms
...' Store these values in strData
w.Documents.Add ' Add a new document to word session
w.Selection.TypeText (strMsg)
w.ChangeFileOpenDirectory (App.Path)
w.ActiveDocument.SaveAs FileName:="test" & ".doc", _
FileFormat:=wdFormatDocument, LockComments:=False, _ Password:="", _
AddToRecentFiles:=True, WritePassword:="", _
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, _ SaveAsAOCELetter:=False
w.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
w.Application.Quit
Set w = Nothing
...
...
..
This will save the value in strData in a word file (.doc) in the directory App.path with filename Test.doc
If U want a sample prg, let me know and I'll mail it to you.
The SaveAs portion of this code is got by going to MsWord and clicking Tools->Macro->Record New Macro and give macro name.
Then type any text in the doc. U then click file,->Save As
and then give a filename an hit Ok.
Then Tools->Macro->Stop Recording.
And finally Tools->Macro->Macros and Click Edit after selecting the macro u saved.
Just cut and paste the code generated.
To save it as another type(html, rtf, etc) select that type in when saving the doc.
If u want more info on manipulating word , let me know....
Hemang
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|