Modules & VBA :: How To Send Embedded Word Document As Email
Dec 17, 2013
I'm using ACCESS 2010. I have a form which is having a embedded word document. What I'm trying to do is i want to enable user to format a mail in the embedded word document which will contain rich text and screenshots then with a click of button an outlook mail should open and content of this document should be pasted there. Once user sends this email, I want to save content of embedded document in the database.
View Replies
ADVERTISEMENT
Oct 7, 2013
I have a Word 2010 document linked to an Access 2010 data source. When a user clicks a button in Access, the Word document loads and performs a email merge using the below VBA code:
Private Sub Document_Open()
With ActiveDocument.MailMerge
.Destination = wdSendToEmail
.SuppressBlankLines = True
[Code] ....
However, as the .mailsubject part is not in the loop it is only retrieving the first Return Code. I have tried to integrate in the loop to no avail. Also, how do I add static text to the Subject, I need something like "Your Return Code" + "Return Code"..
View 6 Replies
View Related
Jun 8, 2007
OK - bit of a newbie here & maybe this question has been asked a thousand times but i can't find any answers that cover this question properly.
Basically i am writing an access database that stores contract information, contact details, orders etc etc. I want to take the Order Number field, along with the Client Name & Address etc and post it into a Word Mail Merge type document, then save that file as ordernumber.doc after checking to see whether it already exists.
I have successfully managed to send the information into word in a mail merge document & get it to save the file using the ordernumber.doc format, however it is saving it to mydocuments folder and i want it in a subfolder called orders (that does exist). It is also not checking to see if that file already exist and overwrites it if it does.
I want to change the path to where the file is being saved, check whether it exists already, then ask me whether i want to overwrite it or save as something else.
Any help would be most appreciated. BTW I am using Word & Access 2003.
*****THIS IS THE CODE I AM USING*****
Private Sub NewEternit_Click()
On Error GoTo NewEternit_Err
Dim objWord As Object
'Start Microsoft Word.
Set objWord = CreateObject("Word.Application")
With objWord
'Make the application visible.
.Visible = True
'Open the document.
.Documents.Add ("\shentcDocuments and SettingsJohn.SHENTMy DocumentsTemplatesEternit Order Merge.dot")
'Move to each bookmark and insert text from the form.
.ActiveDocument.Bookmarks("orderno").Select
.Selection.Text = (CStr(Forms!frmOrderDetails!ContractNo) & "/" & (Forms!frmOrderDetails!OrderNo))
.ActiveDocument.Bookmarks("Date").Select
.Selection.Text = (CStr(Forms!frmOrderDetails!Date))
If Me.chkDeliverYard = False Then
.ActiveDocument.Bookmarks("ClientName").Select
.Selection.Text = (CStr(Forms!frmOrderDetails!ClientName))
.ActiveDocument.Bookmarks("SiteReference").Select
.Selection.Text = (CStr(Forms!frmOrderDetails!SiteReference))
.ActiveDocument.Bookmarks("SiteAddress1").Select
.Selection.Text = (CStr(Forms!frmOrderDetails!SiteAddress1))
.ActiveDocument.Bookmarks("SiteAddress2").Select
.Selection.Text = (CStr(Forms!frmOrderDetails!SiteAddress2))
.ActiveDocument.Bookmarks("SiteAddress3").Select
.Selection.Text = (CStr(Forms!frmOrderDetails!SiteAddress3))
.ActiveDocument.Bookmarks("Town").Select
.Selection.Text = (CStr(Forms!frmOrderDetails!Town))
.ActiveDocument.Bookmarks("City").Select
.Selection.Text = (CStr(Forms!frmOrderDetails!City))
.ActiveDocument.Bookmarks("Postcode").Select
.Selection.Text = (CStr(Forms!frmOrderDetails!Postcode))
Else
.ActiveDocument.Bookmarks("ClientName").Select
.Selection.Text = "OUR YARD"
.ActiveDocument.Bookmarks("SiteReference").Select
.Selection.Text = ""
.ActiveDocument.Bookmarks("SiteAddress1").Select
.Selection.Text = ""
.ActiveDocument.Bookmarks("SiteAddress2").Select
.Selection.Text = ""
.ActiveDocument.Bookmarks("SiteAddress3").Select
.Selection.Text = ""
.ActiveDocument.Bookmarks("Town").Select
.Selection.Text = ""
.ActiveDocument.Bookmarks("City").Select
.Selection.Text = ""
.ActiveDocument.Bookmarks("Postcode").Select
.Selection.Text = ""
End If
'Print the document in the foreground so Microsoft Word will not close
'until the document finishes printing.
'objWord.ActiveDocument.PrintOut Background:=False
' Save the file using orderno field
Dim FName As String
FName = Forms!frmOrderDetails!OrderNo & ".doc"
'Quit Microsoft Word and release the object variable.
'objWord.Quit
'Set objWord = Nothing
End With
Exit Sub
**** END OF CODE****
View 4 Replies
View Related
Nov 12, 2014
I have a template letter in Word that I want to import into Access, so when I choose from a combo box an employee's ID, it automatically displays a report using the Word document template and filled with all related information of that employee (name, nationality, etc.) + it shows today's date. Then I can Save&Email to an Outlook contact.
View 2 Replies
View Related
Sep 29, 2013
I have code that automatically send emails out from an Access Customer Contacts Database. I am using Access and Outlook 2007 but the code needs to work with later versions of Access and Outlook.
I have very poor knowledge of coding and usually manage to cobble something together from looking at other code on the net but don't understand most of it.
I have the following code which works perfectly except I want to be able to embed an image in the email body (not have the image as an attachment but actually show it in the body of the email).
Most of the code I have found around this topic is too complex for me to understand and utilise within the context of the code I have.
Ideally I want to take the image from an attachment field in a table returned by the "tblMailingList_Query".
Code:
Private Sub Command10_Click()
Dim MyDB As Database
Dim MyRS As Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
[Code] .....
View 2 Replies
View Related
Dec 26, 2014
I use the following code to achieve following
a) Open a word document from MS access / VBA,
b) Connect to data from a query
c) mailmerge it
d) Save it as a new document containing mailemerged letters.
The code does open the required document as I can see it open.
I put a message box to recheck that filename/path is what I mean, and to to know till which line the code runs. Code runs till that point and that word doc is seen open. I get the error message before
Then I get error message.
I was fooling around and was getting message " This command is not available because no document is open" I tried to remove few lines thinking redundancy. Before getting the message, I was also getting the error trapping message "No documents opened."
Now I am getting different message.
I am getting message " The remote Server Machine does not Exist or is unavailable"
Following is the code I have written.
Dim xlApp As Object
Set xlApp = CreateObject("word.Application")
xlApp.Visible = True
fn = FormPathName("941 2014 AutoOpen.doc")
[Code] .....
View 5 Replies
View Related
Jul 18, 2015
We need to replicate an Access report we have in Microsoft Word. The report has a fixed, small image in the header and so we embedded it in the report (it is not in an external file). To put this image in the Word document the only way we have come up with is shown in the code below.
Code:
Dim apWord As Word.Application
Dim doc As Word.Document
Set apWord = CreateObject("Word.application")
doc.Shapes.AddPicture "G:ImagesSinful Banner.bmp", False, True, 0, 0, 540, 42
Which requires an external image file. We really would like to avoid this. We could make a template Word document, but that too would be an external file. We know how to put this image in a table as an OLE object, but can't find any way to get it from the table into the Word document.
View 12 Replies
View Related
Aug 21, 2014
Not sure if this is possible but I am trying to extract data from a word document to set up a database.
Basically I am trying to capture data from completed forms, similar to the sample attached, the actual blank form is 20 pages long and once completed can be as many as 30 pages, or even more, although the format doesnt change (i.e. individidual cells will expand to fit the data in the cell).
I want to be able to scan through the completed forms and extract the data i.e. Full Study Title, Short Study Title, Study Type etc. into a database.
The issues:
1. Each document will have a different name but will be stored in the same location.
2. What is on page 8, for example, in one document is not necessarity going to be the same on every document (due to expanding cells)
3. Each sector is in a separate table but tables can spread across several pages.
4. Some data is stored in a checkbox format rather than text.
5. I dont want to extract all of the data, only certain sections (at least at this stage).
View 1 Replies
View Related
Mar 18, 2015
If I use the word template named "ABC.dot" as attached and write the following piece of code to print off the letters with different appropriate background , it works perfectly fine:
Code:
Sub PrintLetters()
Application.DisplayAlerts = False
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim r As Long
Set cn = New ADODB.Connection
[Code] ....
But if I combine two templates together in one template as attached "Capita.dot" then it doesn't display background picture at all in any of the cases. I am using the same piece of code but the background image is not displaying. The background image shows logos for each letter like For capita letters , the logo will be capita . For Friends Life letters the logo background will be different.
View 1 Replies
View Related
Oct 27, 2014
I was tasked to create an application where by the user enters keywords into an Access form, and when he clicks the button, it will run the keywords against the file names stored in the table and automatically open the Word document that is the best match.
I have created a table query called Directory, which contains FPath (Z:), FName (Document1.doc) and Directory (Z:Document1.doc).
Code:
Private Sub Command2_Click()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim filepath As String
Dim strSearch As String
If IsNull(Me.txtSearch) Or Me.txtSearch = "" Then
MsgBox "Please type in your search keyword.", vbOKOnly, "Keyword Needed"
[Code] ....
This is the code that I am currently using to search and open the Word documents, however, this code only manages to open Microsoft Word program without loading any documents. Also, there are no error messages when I click the submit button.
View 3 Replies
View Related
Mar 19, 2015
There are two pages in a word document. All the pages have same headers as attached in word document "Capita.doc". I want to display that header on just first page and on second one page, I want to display watermark stored in "J:PAP107.jpg". The following code displays same watermark on all the pages i.e "J:PAP107.jpg" but I want to keep the header as in the attached word document on first page only and display watermark stored in "J:PAP107.jpg" on second page.
Code:
Private Sub CmdPrint_Click()
Call WordSetupQA("C:CAPITA.dot", "J:PAP107.jpg", Format(DateSerial(ComboBox4, ComboBox3, ComboBox2), "mm/dd/yyyy"), pno)
End Sub
Code:
Sub WordSetupQA(fnTemplate As String, fnBackGroundPic As String, b As Date, a As String)
On Error Resume Next
'MsgBox txtbox
Application.DisplayAlerts = False
Dim strworkbookname As String
strworkbookname = "C:System1.mdb"
Set WordApp = GetObject(, "Word.Application")
[code]....
View 1 Replies
View Related
Dec 17, 2013
I am trying to export an attachment item (Picture .jpg) to a word document. I have been exporting text to a word document successfully with below syntax "
With rst
strLandSalesID = Nz(.Fields("LandSalesID"))
strPhotograph = Nz(.Fields("Attachments"))
However, attachment do not work.
View 3 Replies
View Related
Aug 5, 2013
I am having the strangest results with my automated mailmerge. Basically it does work, but not all the time. The basic idea is to allow the user to dynamically create a query that produces a result list which fills a temporary table. The use then selects a prebuilt merge template and merge is executed against the temp table. The merge template are of the .doc type, but sme have been converted to .docx; the .doc files tend to work most often, but all of the will eventually get a Table is locked message... However if I run in test mode with code breaks and manually step through the process it always works... here is the heart of the code ...
Err_Pos = 10
Code:
DoCmd.SetWarnings False
' if tmp tbl left over from last run kill it
DoCmd.RunSQL "Drop table Word_Merge_Tmp_TBL"
Err_Pos = 12
[Code].....
There are many error cases in the error catch routine. That I have managed to make Access stop hanging when word has a problem or the table is locked. But I can't get the table to be free consistantly and why does it always work when I manually step through the code.
View 4 Replies
View Related
Apr 10, 2014
Like the title says it:
Is it possible to link/export a query to a existing Word document?
I have several Word documents with text, and i want to place the data of a few query's in those documents in a certain place.
Is this possible true vba or another way?
View 4 Replies
View Related
Jun 14, 2014
copying all the contents/text from word document and pasted that in the Memo Field, I have a Recruitment database where I have 02 fields on is CV Path (Text Field) that stores the CV Path (Word Document Path) and another text box content (Memo Field) where I would like to copy all the data from the word document to the Content text box (Memo) field.
I have put a Command button on the form...the code to "Copy the content/text" from [CV Path] word document and add it to the "Memo" field.
View 1 Replies
View Related
Jan 12, 2015
I'm trying to work out how to attach a word doc to the attachment field of a table when I add a new Record. The following code work's fine if I add it to the On Load Event on the Form, but the doc is attach'd to the first record. When I add the code to the Add New Record button, I get the error msg: "File already part of the Multi-Valued Field" and nothing in the attachment field.
Code:
Private Sub Add_Record_Click()
DoCmd.GoToRecord , , acNewRec
Me.Description.SetFocus
On Error GoTo Err_AddImage
Dim db As DAO.Database
Dim rsParent As DAO.Recordset2
Dim rsChild As DAO.Recordset2
[Code]...
View 8 Replies
View Related
Aug 4, 2014
Is there a quick way to export ALL VBA code to a text file/word document?
View 5 Replies
View Related
Jul 29, 2013
Is it possible to update the data for a chart graph in a word document from Access using VBA?
View 4 Replies
View Related
Jul 2, 2015
I have a form with fields that contain the address/postcode etc of the person in question, and I also have a template letter that needs to have said persons address/postcode etc at the sending stage after a button is clicked.
View 9 Replies
View Related
Feb 11, 2014
I have the code for sending an email but I only want to send a single email when there are records in a query and only when the database is first opened.
I hadn't considered this in my design so what structural requirements would it require if any?
View 5 Replies
View Related
Aug 1, 2013
I have an Access 2010 database which has a table with several fields with the Hyperlink data type. Some of these hyperlinks reference files stored in a SharePoint database. I am relatively new to using hyperlinks. The task is to insert those hyperlinks into an email using VBA so that the recipient can just click on them to view the documents.
I have no problems with using VBA to create emails or to add attachments. My issue is with adding hyperlinks to the body of the email.
View 12 Replies
View Related
Jul 2, 2015
I have a several templates in outlook 2003 for my charity work.
All is OK if I send the odd one now and again, but the workload is increasing with more and more at any one time. However having seen various posts on here, I was thinking I could set something similar in Access as well as keeping track of the payments & deposits more easily.
I am fine with to, cc,bcc, body, subject etc, but what I need to do is SendUsingAccount, but 2003 does not have this property, it started with 2007.
As well as sending on that particular account I also need the signature linked to that account.
I could add that signature by code if I can get the correct account and for some reason the signature is not added.
I tried using SendOnBehalfOfName which works as far as the correct email address is used, but still uses my default a/c.
As an aside, my Outlook session would always be open, so I will use GetObject and not CreateObject method, but would like not to have the warning dialogue in Outlook pop up all the time.
View 14 Replies
View Related
Jan 15, 2015
With the code below , I send the report: “ESERT4H”, in email body. How I could add yet another report on the same body of the email ?
DoCmd.OutputTo acOutputReport, "ESERT4H", "HTML(*.html)", "D:Access empESERT4H.html", False, "", 0, acExportQualityScreen
Dim Out As Outlook.Application
Dim NS As Outlook.NameSpace
Dim Folder As MAPIFolder
Dim Mens As MailItem
[Code] ....
View 7 Replies
View Related
Aug 13, 2014
I have inventory database, in database there is "NextScheduledMaintenance" field.
I want access to send email automatically when scheduled maintenance date due.
View 7 Replies
View Related
Feb 3, 2014
I'd like a command button to open Outlook and create a new email message with the To and Subject fields already populated with what I want, is there anyway to do this?
View 1 Replies
View Related
Aug 17, 2015
Is it possible to send an email from an access 2007 database with a category?
View 8 Replies
View Related