Modules & VBA :: Word Automation From Access - Tables
Aug 1, 2013
I have just started to develop a database that will export data directly into a word template. I have used Word automation quite a lot but I'm new to trying to automate Word from Access.
It's going OK at the moment, I have got the db to open up the template, write data and then close. My objective is to add the data to multiple tables within word. So I have created several tables in my word template and then tried to select these tables and write to the them. Everything is thing for the first table but for any other table I get an error message saying that the member of the collection doesn't exit i.e. the table isn't there. I select the table using:
Code:
objWord.selection.tables (2).select
I then used:
Code:
objWord.selection.tables.count
To show how many tables were in the document and it doesn't matter how many there are, it always says there is 1 table.
why it can only see 1 table and what I can do to get around it?
View Replies
ADVERTISEMENT
May 14, 2015
I have programmed a letter using automation to Word VBA. The letter works like a mail merge so it might cycle thru several records when it runs. I've separated each letter in the document with a section break. I'm having a problem with the header. I've successfully added a header, but when it moves to the next record, it replaces the header in the entire document with the current record. I want each section to insert data from that record. How can I fix this? Below is a sample of my code (note: the linktoprevious doesn't seem to work either).
x = 1
'Create Header
With ActiveDocument.Sections(x)
.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
.PageSetup.DifferentFirstPageHeaderFooter = True
[code]....
View 1 Replies
View Related
Nov 26, 2013
I have a MS Access 2010 application when the User opens form CONTACTS Form
◦User finds single record to be used CONTACTID is identifier to be used for selection
◦User clicks button to open form frm_MAIL_MERGE
◦Frm_MAIL_MERGE has a drop down combo box that reads the folder location where the application resides and displays all .DOTM files (that is all template files) and one more combo box which contains the CONTACTID.
◦User selects single .dotm file for merge
◦Frm_MAIL_MERGE has either drop down to select CONTACTID or UNBOUND data field for user to type in CONTACTID number
◦User enters CONTACTID to be used for the mail merge
◦User selects SUBMIT
◦Application merges selected .dotm file with the information in table CONTACTS for the selected CONTACTID
◦Merged document is saved on the user Desktop as xxx.docx
View 10 Replies
View Related
Oct 11, 2004
Looking for a way to count the number of pages in a word document (while in MS Access)
Also looking to delete a page of Word while in Access.
View 1 Replies
View Related
Sep 26, 2013
I'm trying to create an export to word but am having some trouble. I keep getting the following error;
Run time error '91'; variable or object of With block not defined.
This error occurs at Set TblWord = docNew.Tables.Add(Selection.Range, 3, 5)
I have a feeling its 'Selection' that is causing the problem but I can't work it out!
Code:
Dim AppWord As Word.Application
Dim DocWord As Word.Document
Dim TblWord As Word.Table
[Code]......
View 4 Replies
View Related
Sep 27, 2012
I have a table in MS Access 2010 with a Date field and 3 Memo fields. I wish to append data to the Access table from a MS Word doc that has a date field and 3 memo fields. My wish is to have a command button on the MS Word doc which appends the data to my Access Table.I am aware that a web page can append data to an Access table.
View 2 Replies
View Related
Nov 25, 2014
I have a database of film events, for which i have to do posters.
With the click of a button on a form, access opens word and puts all the fields in, including a field called [photo], which is the name of the image stored outside of the database.
Is there a way of getting that image into the word Document with all the other fields? Or have I just wasted an afternoon....
View 2 Replies
View Related
Jul 28, 2013
I'm doing a project for my work. I created a few reports in Access. Some of these reports are simple graphic bars. How can I insert these reports into a word document template?
View 2 Replies
View Related
Mar 9, 2014
I often create contract using mail merge. I have an access file that I want to use as data source for word file. But it does not automatically.
Please see the attached file !
If there are 1 customer and 1 property, I do not need to do anything. Conversely, if there are many customers and many properties, I take time to manipulate.
Firstly, I open the word file. I have to copy and paste paragraphs that I want. Highlight of the original paragraphs is blue.
Secondly, I click 'Insert Word Field' -> select 'Next Record'.
In short, I want to use VBA in access file to automatically perform the steps that I have outlined.
View 1 Replies
View Related
Apr 21, 2015
I need to create a word file (it needs to be word) based on template (not a very complicated template) max 1 to 1 and 1/2 pages long.
the word doc needs to be named from the recordset but for now assume 12345.doc and the next one will be 12346.doc etc (I have a unique number system - available from tables /query .
i can either make the word doc in code or use a template (template would be better) recordset could have 20-30 in it each time i run it - but to be run every week
second half is how to email this out. i had in mind a email system
email to . test@testhotmail.xyz
file attach = this folder where the docs are store and attach 12345
in a loop
so either
create word file - email word file in a loop each time or create all the word files and then send them individual
View 4 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
Aug 7, 2015
I'm opening a second database (db2).
Copying the structure of a db2 table to db3.
Populating the table in db3 with a subset of records from db2.
I've gotten as far as opening the db2 and copying the table structure. Can't figure out how to run the query using execute rather than docmd.openquery.
Code:
Dim appAccess As Access.Application
Set appAccess = New Access.Application
appAccess .OpenCurrentDatabase "DbPathString"
'copy the table structure to dbQn, overwrites any previous with same name
[Code] ......
View 4 Replies
View Related
Aug 2, 2013
I'm trying to add a value from access into a combo box on a web page. I can get the combo box to refresh, but not add in a value..The HTML for the combo box is
<tr><td align="right">Campaign: </td><td align="left"><span id="LogiNCamPaigns"><select size="1" name="VD_campaign" id="VD_campaign" onfocus="login_allowable_campaigns()">
<option value=""></option>
And I've been using
ie.Document.all.Item("VD_campaign").focus
To refresh it (works great)
And attempting to put a value into it (which is an option in the combo box)
ie.Document.getElementById("VD_campaign").Value = "201 - Campaign-1"
But nothing happens - not even an error
View 1 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
Jun 3, 2015
I have a form that I have exported certain fields into a word doc (it is up and running just fine). I created bookmarks in word and put some VBA into my access form, so when I click on 'Create word report' it pops up and automatically populates the record I am on. Here is the tough question,
How to make this work with a continuous form? My main form has several subforms, one being a continuous form. The main form shows one bridge at a time. The sub continuous form shows information for all of the bridges spans (could be anywhere from 1 to 9).
View 4 Replies
View Related
Jul 8, 2013
I like to do following task using access VBA:
1. Open outlook.
2. Select word file(with tables and graphics) and insert into new outlook email.
View 1 Replies
View Related
Jul 31, 2015
I get the message "The expression On Click you entered as the event property setting produced the following error: Class does not support Automation or does not support expected interface"
I receive the message on a PC running Windows 7 Professional using the Access 2013 Runtime. This pc does not have Access 2013 installed.On my pc, I do not get the error. I have Access 2013 installed and run Windows 7 Professional SP1. The "code" which gives the error is as follows and is invoked by clicking a button on a form
Code:
MsgBox "1"
Dim rst As ADODB.Recordset
MsgBox "2"
Set rst = New ADODB.Recordset
MsgBox "3"
[code]....
The error takes place after Msgbox "2" and before Msgbox "3".The strange thing is that I can run without a problem a sophisticated software package on the pc which gives the error, using Access 2013 Runtime. This package I converted from Access 2003.
View 3 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
Sep 2, 2013
I'm trying to tick "Yes" to a radio button which are side by side on a web page (Yes and No). The HTML is below and the VBA I'm trying to use is:
ie.Document.all.Item("newsletter").Checked = "0"
I've also tried
ie.Document.all.Item("newsletter").Checked = "True"
ie.Document.all.Item("newsletter").value = "True"
ie.Document.all.Item("newsletter").value= "0"
<table class="form"> <tr> <td>Subscribe:</td>
<td> <input type="radio" name="newsletter" value="1" /> Yes
<input type="radio" name="newsletter" value="0" checked="checked" /> No
</td> </tr> </table> </div>
View 6 Replies
View Related
Jul 28, 2006
I would like to create a program within access that is linked to a specific folder on my C: drive and waits for a file to appear within the folder. Once the file appears, i would like access to process the file and return the output back to the folder. Is there a way to do this?
example: test.txt appears in folder C:Test. Access grabs the txt file, opens it, processes the information and then writes the output back to C:Test. I will need access to continously check the folder for new files.
thank you
View 1 Replies
View Related
Oct 28, 2004
I'm trying to take a value in an Access form text control and populate a single cell in an Excel file.
I can open the file I just don't know the VBA syntax to populate accordingly. Any help will be appreciated.
Thanks.
View 2 Replies
View Related
Dec 7, 2004
My table has pre existing data in 5 fields. I want to be able to schedule
and automatically append 25 records to the fields once a week. What is
the best way to approch this.
Thanks
View 1 Replies
View Related
Jul 24, 2014
I'm about to connect my DB to word. So I made a form where the user has to choose what entry to export. The data is inserted in a word file in different bookmarks. But there is one special task to insert the rich text so in this case the html formatted text is displayed like this:
Code:
<html><div>asdf</div></html>
My Text is inserted like this:
Code:
wdApp.ActiveDocument.Bookmarks("-Bookmarkname-").Range.Text = Lrs("-ColumnName-")
Lrs is a Recordset.
So how is it possible to display the html code right in the Word doc?
View 1 Replies
View Related
Jun 2, 2014
I am running Office 2010 but at one time also had Office 2013 installed on my Windows 7 64 bit OS PC. The first attachment (AccessProblem) shows the error message that I get when it hits the
Set olApp = CreateObject("Outlook.Application")
line. I get the automation error - library not registered error. The second attachment (Access2Problem) shows the references that I have.
View 2 Replies
View Related
Nov 19, 2013
I developed a finance tracker database for tracking project revenues and costs (forecast and actual amounts). I have a form where we enter a new Work Order in the DB. This Work Order form has a continous subform where we create all the billing periods needed for the life of the Work Order. Once the billing periods are created (opened) we can then add our revenue and cost forecasts for each period. We have a Billing Period lookup table that has our billing periods with their respective start and end dates (which usually begin around the last week of a month and end about 3 weeks into the next month).
For the purpose of this question, lets say we only enter the required WO_Number and WBS_Code (Composite key) and the Work Order Start_Date and End_Date. I want to click a button to runs some code to automatically create all the billing periods for which their start and end dates fall into the Work Order start and end dates.
For example, say a Work Order starts on 5/1/2013 and ends on 7/31/2013
The billing period dates in the Billing Periods lookup table are as follows:
May-13 ---> 4/22/2013 - 5/19/2013
Jun-13 ---> 5/20/2013 - 6/23/2013
Jul-13 ---> 6/24/2013 - 7/21/2013
Aug-13 ---> 7/22/2013 - 8/18/2013
Then we would need the following billing periods created in the Work Order subform:
May-13
Jun-13
Jul-13
Aug-13
I don't even know where to start on this. Is it possible to automate this process with the setup I have? If so, how would I structure the VBA code/logic to use the billing period lookup table and create entries in the subform for all the billing periods that fall into the duration of the Work Order.
The attached DB is a stripped down version with only the tables and forms needed for this problem.
View 2 Replies
View Related
Apr 1, 2015
I have a form on access which allows users to upload csv files.
The files can be in any layout, so the field names and the number fields will always be different each time.
This can cause issues on data types, as access assumes a certain data type for a field, but the data may not always reflect that.
For example telephone numbers, access assumes this is a numeric field, however sometimes there will be symbols in this field such as +44. Which then causes import errors.
Is there any way to import these files without getting these sort of errors?
Currently the import process uses a simple TransferText method
DoCmd.TransferText acImportDelim, , "Original Data", Me.filelist.RowSource, True
This imports the data into a new table called 'Original Data'.
I had the idea of saving the table structure of the csv being imported (Importing the data with errors, then deleting all the records to just leave the structure) However I can't find a code to change the data types of that table to TEXT format, when I can't tell what the field names will be.
This whole thing is an automated process, which why there are loads barriers btw.
View 14 Replies
View Related