Modules & VBA :: Add Different Header In Each Section Using Automation To Word
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 Replies
ADVERTISEMENT
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 2 Replies
View Related
Apr 10, 2015
What I wish to achieve is to create a report that groups and sorts without the need of a header section as it is taking up to much space cascading :
----
----
----
----
----
----
rather than :
---- ---- ---- ----
----
----
---- ---- ----
----
----
I basically want it not to cascade but do the exact same thing as it does inside its own header. (We need to dramatically cut down the page amount as a delivery schedule is printed out daily and could do with the page count around 10 rather than 50 ).
(Links below)
What It Looks Like ....
What I Want ....
View 2 Replies
View Related
Nov 23, 2011
I am creating barcharts in the report header section but i think there is some size restiction and I am not able to add more than 3 graphs in the report header section. I have to add 65 graphs. Is there any way to do that .
View 2 Replies
View Related
Dec 30, 2004
I have a main report with 2 subreports. My main report has a header section, the 2 subreports are in the detail section of my main report. How can i prevent my report from splitting up my header and my subreports. (Header section of my main report is a company and the subreports are the detail of the company.. i don't want my compnay name on the bottom of a page and then the detail on the next page.. it does this sometimes. thanks!
View 5 Replies
View Related
Jul 3, 2013
Working in Access 2007 - I would like to have an updatable calendar in the header section of a form, and when this is changed by the user I would like the subforms (there are several) in the details section to be updated with various appointments with dates corresponding to the date selected in the header.
View 3 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
Nov 22, 2004
I have a report that lists states and cities within the states. When a state name happens to be at the end of the page the individual cities appear on the next page with no State heading. I solved the second page problem by setting the "repeatSection = Yes" in the Section Header (though I haven't shown that in the example below).
But the previous page (which just shows the State Name and no cities looks dumb. Is there some sort of solution.??
(Actually I would also like any State that continues to a next page to not just have the state name but something like
" Colorado (Continued)" Is there anything I can do in VB to make a page break if the section is going to print but therer isn't enough room for one detail line?
This is what I currently see
Alaska
Ancorage
Prudo Bay
California
Whittier
Anaheim
Colorado
------------------------Page Break ---------------------------------
Denver
Pueblo
Colorado Springs
Deleware
Dover
-------------------------------------------------------------------------------------------
Thanks !
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
Aug 13, 2013
I'm trying to create a report where I can use a section header as a hyperlink to show/hide detail, but only for that section. For example, my customer names are:
Code:
ABC Co.
ZYX Co.
123 Co.
If I click on ZYX Co., I want it to show the contracts for ONLY that customer:
Code:
ABC Co.
ZYX Co.
Contract 1
Contract 2
123 Co.
Right now, my code looks like this for On_Click:
Code:
If Me.Detail.Visible = False Then
Me.Detail.Visible = True
Else
Me.Detail.Visible = False
End If
But it shows and hides detail for ALL customers when I do this. Is there a way to only show/hide for the customer on which I click?
View 1 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
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
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
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
Sep 22, 2013
Trying to figure out during the key down event -
a.) how to also stop a leading zero (e.g. don't allow 04, but allow 4)
b.) Don't allow any combination of numbers to be outside 1 to 36
Yes, I can do this on a validate event after the fact. Just wondering if there is anything that could put this all into the KeyDown event to prevent errors in the first place.
This code works great to prevent any key entry except 0..9, Tab, and backspace
Code:
Private Sub txtSectionNumber_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode ' only accept a number 0 to 9 Backspace or Tab
Case vbKey0, vbKey1, vbKey2, vbKey3, vbKey4, vbKey5, vbKey6, vbKey7, vbKey8, vbKey9, vbKeyBack, vbKeyTab
' do nothing and accept the value
Case Else
KeyCode = 0
End Select
End Sub
In the US Western States, a survey township is simply a geographic reference used to define property location for deeds and grants as surveyed and platted by the General Land Office (GLO). A survey township is nominally six by six miles square. They are assigned numbers of 1 to 36.
View 2 Replies
View Related
Jul 8, 2013
I had the need every so often to quickly find all instances of any (particular) word within the database, without going to the bother of thinking about where that word/subject might be in the data base, I designed a report which does the job nicely. It uses a search form/control, searches and finds all instances of the word (or words) I have asked it to find, then does a report showing all instances of whatever RTF memo fields that contain the word(s).It has to be RTF memo field because (if I wish) it goes straight into the book text I'm writing, and also it searches the book's RTF memo field.
.
The trouble is, at present, I then have to manually "eye scan" the resulting report to find the occurrences of the "key searched for" word, nestling/hidden somewhere within sometimes quite large chunks of text. I would love to have the report show the found "key word(s)" highlighted in (say) light blue or whatever colour, so that I can quickly & easily lock on to it visually.
I enter the word I want Access to find, into a form called "formfindword" in a text box called Text0. I click on a command box on this form, to open up the report called "Querywhatsandhowschooseword" based on a query of the same name. The query's "what" field (from the main database) has the criteria
= Like "*" and [forms]![Formfindword]![Text0] & "*"
The query's "how" field criteria (in the "or" line of the query design) is also
= Like "*" & [forms]![Formfindword]![Text0] & "*"
I have tried to use the Conditional Format facility in Report Layout view, without any luck.I think therefore that I will need some VBA code (which is totally foreign to me, unfortunately) to make this simple concept a reality.
View 2 Replies
View Related
May 16, 2015
I'm using VBA to insert the page number in a header. It's working, exept for a couple of things. I want it to insert the page number at the current position, and restart numbering at each section. I increment the section # with the variable x. Currently, it's inserting the page number at top-left of header. I want it to insert the page number after the word "Page" followed by 2 lines breaks.
Here's snippet of my code:
'Create Header
With ActiveDocument.Sections(x)
.Headers(wdHeaderFooterPrimary).LinkToPrevious = False
.PageSetup.DifferentFirstPageHeaderFooter = True
.Headers(wdHeaderFooterPrimary).Range.Font.Size = 9
.Headers(wdHeaderFooterPrimary).Range.Text = "Session: [" & rst!SessionNum & "] " & rst!SessionTitle & _
Chr(13) & "Presenter: " & rst!Full_Name & Chr(13) & "Page " & Chr(13) & Chr(13)
.Headers(wdHeaderFooterPrimary).PageNumbers.Add pagenumberalignment:=wdAlignPageNumberLeft, FirstPage:=True
End With
View 5 Replies
View Related
Aug 28, 2013
I have a saved import that my office will be performing monthly (or more often). We pull a report from another system that comes out in a delimited text file. I prefer to keep the header row in the document - I don't want to force my personnel to remove the header row, but I also want the header row to be available in case we need to import it to Excel or provide it to other users - with no header row they may not be wise enough to figure out what some of the data details.
However I receive the "Unparsable Record" error currently when importing.
Is there a way to prevent the first row from importing to the table so we don't get an error table created?
Code:
Private Sub UsersUD_Button_Click()
Dim Alert
Alert = MsgBox("Have you updated the F9046REP text file?", vbExclamation + vbYesNo, "Confirm Update")
If Alert = vbNo Then Exit Sub
DoCmd.RunSQL "DELETE * FROM F9046REP_Table"
DoCmd.RunSavedImportExport "F9046REP_IMPORT"
End Sub
View 3 Replies
View Related
Feb 20, 2015
I have a mainform. When I click on a command button, it opens up another form. That form is designed to be as a continuous form, yet it does not display the header. The header is present in the form view. I have attached the screenprints to show the header in my form and the corresponding properties window.
View 4 Replies
View Related
Jul 10, 2013
A user requested a change that would change the form header and detail back ground color to white when they click the button print record and then change the color back all in one click after the record prints. I keeping getting a run time error, type mismatch on the line where to code is to be changed. The colors are numbers not vbColors. I am using Access 2007.
Code:
Me.FormHeader.BackColor = "#FFFFFF"
Me.Detail.BackColor = "#FFFFFF"
View 3 Replies
View Related
Feb 27, 2015
I'm creating a folder with values from some fields. It all goes OK, but, the only thing is that the name of the folder could get to long.
We use words like "Prototype Model" "Prototype Review" Next Date Review" "Next Prototype Review"
How could I end up with only the first letter from each word like "PM" "PR" "NDR" "NPR" from a field called Type_Review ?
View 14 Replies
View Related
Mar 14, 2014
I'm using the below to merge from acces to word and create a new doc. All is well.However I need to save the output file type as PDF.When I try to change the docx to PDF, it corrupts?
Dim wordApp1 As Word.Application
Dim docPath1 As String
Dim fileName1 As String
docPath1 = Application.CurrentProject.Path & "Merges"
fileName1 = docPath1 & "CreatedCover Letter.docx"
Set wordApp1 = New Word.Application
With wordApp1
[code]...
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 30, 2013
I have below vba code in a sub that opens word application and generates the data from a table based on criteria provided thru a form.
These lines are smoothly working..
But I need to place some headings in first line or second line of the document and then to start the table information to appear in the doc.
I tried to place my company name below way (see bold lines);
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim I As Integer
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT * FROM T_CustomerMaster WHERE SALESMANCODE='" & Forms!F_ReportMaster!TxtRepCode & "' order by custcode;")
WordSetup
doc.Tables.Add Range:=doc.Range, numrows:=1, numcolumns:=5
'Trying to place main heading
'doc.Range(1, 0).Text = "fsdafds"
[Code] ....
But the table starting from column 1 and cell 1 till data ends up.
Finally I converted my trial lines to remark as it is not working at all.
View 8 Replies
View Related