delete line containing a certain text string
I receive files containing many lines starting with the word 'Table' and
ending with the string '== =='. These are interspersed with a few lines also
beginning with 'Table' but ending with various different strings. I want to
delete the lines endiing '== ==', leaving only the others.
Each line ends with a paragraph mark (after the strings mentioned above.)
I've tried to do this with the Help available in Word and the advice given
in this discussion group but so far failed. Can anybody help?
--
Terry Sycamore Tag: Word 2007 Color Scheme Tag: 115102
Blind print out of pages
I am to build a template for users to use and what it is to have is a button
that prints our specific sections of text. Basically, a user locates a
heading in the document and then clicks on the button and the code in the
button has to figure out how many pages are under that heading and print
them. How would I code something like that? Tag: Word 2007 Color Scheme Tag: 115100
HELP! Text Form Fields values disappear on print
I have a word document with over 400 text form fields. The fields are filled
in through a user control. When I print preview the document, it looks fine.
When I print it, the first thing that happens is all of the values in the
text form fields disappear. Any ideas would be greatly appreciated.
Thank you,
SoCal Rick Tag: Word 2007 Color Scheme Tag: 115093
Filtering Columns in Word?
Hi,
Iâ??m trying to implement something similar to AutoFilter in Excel. I have
several tables in a document. Two of the columns in each table are called
â??Service Descriptionâ?? and â??Type of inspectionâ?? respectively. Since there are
only three Types of inspection, a simplified version of those two columns
could look as follows:
â??Service Descriptionâ?? â??Type of Inspectionâ??
Description1 C1
Description2 C1
Description3 HGP
Description4 HGP
Description5 MI
Description6 MI
Let's suppose that every table has something similar to what's shown above.
What I would like to accomplish is that through the click of a button or a
macrobutton field or whichever you consider is the most appropriate event
handler, every table in the document gets filtered based on the Type of
Inspection.
I was thinking about having three macrobutton fields, called "CI", "HGP" and
"MI", so that upon double-clicking "CI" for example, every table in the
document hides/unhides the appropriate rows. (i.e it only shows the rows that
correspond to a CI Inpection Type).
Is there a way to accomplish this? How can I refer to each table in a
document? and moreover, How can I select the appropriate range to hide it
based on the clicked button?
Thank you,
Juan Tag: Word 2007 Color Scheme Tag: 115087
Word Macro for Printing Sections
Hello,
We have a form letter which is 2 pages. We do a mail merge from an
Excel sheet. The mail merge creates a new word document with all of
the form letters addressed to the different addressees. It appears
that Word turns each set of pages into a section. This is fine. We
then fax these to the addressees using our fax printer. I have created
a macro that prints each section as an individual document which then
gets faxed to the customer. The problem is the number of sections is a
variable. One week it may be 90 the next it may be 100. The macro I
created has 140 print sections in it. This works fine until the last
section. Because the macro has 140 sections the last fax has not only
the 2 pages it should have but then it back tracks and adds an
additional 2 pages until it gets to 140. So the last fax may have 80
pages in it. I need the macro to understand how many sections there is
and stop when it gets to the end.
Any advise would be great!
Thank you. Tag: Word 2007 Color Scheme Tag: 115086
Preventing macro from copying over from template to document
I have made a template which just puts in a date range then autosaves
the file to a particular name when you close it. This create a new
document, but all the macro coding from the template file is copied
into the document. How can you set it so that the coding from the
template isn't copied into the document?
I would also prefer if the file isn't saved on close, but if the name
and location of the document is just set by the macro (so when you go
file>save it still lets you change the name and location if you want).
But i coulnd't get it to go to the right directory.
This is the code i have:
Private Function WeekStart() As Date
Dim wday As Byte
wday = Weekday(Date)
Select Case wday
Case 1
WeekStart = Date
Case 2
WeekStart = Date - 1
Case 3
WeekStart = Date - 2
Case 4
WeekStart = Date - 3
Case 5
WeekStart = Date - 4
Case 6
WeekStart = Date - 5
Case 7
WeekStart = Date - 6
End Select
End Function
Private Sub Document_Close()
Sunday = Format(WeekStart() + 7, "d")
Saturday = Format(WeekStart() + 13, "d MMM yy")
FileTitle = Sunday & " - " & Saturday & ".doc"
ActiveDocument.SaveAs "J:\Editorial\Magellan\Sickness Absence\Afghan\"
& FileTitle
End Sub
Private Sub Document_New()
Selection.GoTo What:=wdGoToBookmark, Name:="DateRange"
Selection.InsertBefore Format(WeekStart() + 7, "dddd, d MMMM")
Selection.InsertAfter " to "
Selection.InsertAfter Format(WeekStart() + 13, "dddd, d MMMM yyyy")
End Sub
Thats all in the ThisDocument module.
Thanks Tag: Word 2007 Color Scheme Tag: 115079
How can I get the time of the last input event (key and mouse
I have done a small program in VB.NET that uses the GetLastInputInfo
function to retrieve the time of the last input event. It checks every
second and it works well in Windows XP. However, when I install the
program in VISTA it crashes.
Does anyone know how I can get the time of the last input event (key
and mouse activity) in VISTA?
Any direction and help is most appreciated!
Best regards,
Tomas :) Tag: Word 2007 Color Scheme Tag: 115076
Selecting a paragraph
I need to add '<B>' at the beginning and '</B>' at the end of the particular
paragraph then move to the beginning of the next paragraph. The following
works if the insertion point is at the beginning of the paragraph but falls
down if not.
I have tried various key combinations to try to get to the beginning of the
paragraph but if the insertion point is already there they fall down too.
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Please help
Francis Hookham
Sub htmlBold()
Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend
Selection.Cut
Selection.TypeText Text:="<B>"
Selection.PasteAndFormat (wdPasteDefault)
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="</B>"
Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub Tag: Word 2007 Color Scheme Tag: 115071
Template with Conditional Formating
I am looking to create a template or form in Word 2003 that will contain a
variable number of items each with a drop down list. For example...
Body Text
Exhibit A: Drop Down List
...
Exhibit N: Drop Down List
Body Text
The drop down list for each exhibit will be the same, but the drop down item
selected for first exhibit would be different from the next. I want a way
for the user to indicate what their last exhibit will be (any letter A-N),
lets say 'D' and then only have Exhibits A through D be available. Also,
when the template is printed then only the relevant exhibits and body text
should print. Any help would be appreciated. Tag: Word 2007 Color Scheme Tag: 115069
Continuous Numbering of Pages Across Files
I'm trying to consecutively number pages across a large number of files that
are all in the same folder. I'm trying to use the IncludeText field tip that
Cindy Meister mentions on her website but I'm running into all sorts of
weird problems. I've had this working on a few files and then "magically"
the fields no longer work and indicate there are syntax errors. I'm talking
about in the files that were working.
Does the IncludeText method actually work? Is there a better method? I'm
using Word 2003 under Windows XP.
Thanks in advance for any help/tips.
Brian Tag: Word 2007 Color Scheme Tag: 115066
Word 2007 Global Building Blocks
Hi,
I have put my Word 2007 autotext entries into one file as a BB.dotx
and saved it in the default startup directory as noted in file
Locations. I also create a .dotm macros file that access any custom
autotext from that BB.dotx file.
There is another program that has a template in the same folder. For
some reason when this other programs template is running I get an
error that says my BB.dotx or Macros.dotm file says it is read-only.
The .dotx and .dotm files get pushed out to the users C:/ drive and is
not on a network. If I change my Macros.dotm file to be 2003
compatible then only the bb.dotx file gives an read-only warning.
Now I noticed if I saved my BB.dotx file to the ...\Application Data
\Microsoft\Building Blocks folder, then I don't get the error
anymore. However the problem is I don't want the Building Blocks to
be in the users directory. Is there a way to change the global
location for Building Blocks or a better way of doing this?
Thank you for your time and help.
Kerri Tag: Word 2007 Color Scheme Tag: 115060
Macro to access Outlook 2007
Hello,
Ok, so here's my issue. Do to the security settings in my office, Outlook
2007 is set up so you can not write any VBA code or create any macros. But I
have this report that is made up every morning and I have began the processes
of trying to automate this report in Word 2003, and in this doc I have
calculated fields, linked excel charts/graphs, etc... .
But a couple tables that are in this report are emailed to me every morning.
The emails come as an attachment which opens up IE and displays a table. So
what I'm trying to do(if possible), is to use VB in word to pullOut/extract
or whatever the correct terminology is and place that table into word.
Possible? Tag: Word 2007 Color Scheme Tag: 115048
change font color macro
In Word 2003, I've written a macro to change specific parts of the text in a
document to Dark Red (RGB 128,0,0) with a Find/Replace. I tested and created
the Find/Replace first, then duplicated the actions to record the macro.
When I do the F/R manually, it works just fine; it also works while I'm
recording it. After I finish the recording and run the macro, however, it
does everything EXCEPT change the color. What am I doing wrong and how can I
fix it?
Here's the text of my macro:
' FixResumeProjectName Macro
' Macro recorded 6/25/2008 by klsigel
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "---*---"
.Replacement.Text = "^&"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "---"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Thanks-
Karen Tag: Word 2007 Color Scheme Tag: 115046
Block a document from email
Hello all
I would like to know how to block a document from being emailed, for example
if it had a specific word in it - maybe in the properties. I don't really
want to lock the document and I wondered if there was a way of coding a
template to block it from email. Does anyone know if that is possible?
Thank you.
Aehan Tag: Word 2007 Color Scheme Tag: 115045
Defining a specific range
Hi there,
I'm trying to create a macro that opens Word documents in a folder and
searches for the words "Changes due to". However, I want the search to
take place in a range that starts at the "Overview" word (in a Heading
2 style) and ends when the next Heading 2 is met.
I've done some searches on this forum, but I can't find this specific
definition of my range.
Thanks for any help.
Carlos Tag: Word 2007 Color Scheme Tag: 115041
New Page Event
Hi,
I'm looking for a "new page" event, which insert a text box whenever user
add a new page.
Is that possible?
Thanks,
Faruk Tag: Word 2007 Color Scheme Tag: 115033
Where else can I go for word programming support?
Can anyone recommend other venues for word programming support? I've
been stuck on an issue for a couple of weeks, and for the first time
have not found a resolution by posting here. Are there other forums or
newsgroups where it'd be appropriate to post word programming questions? Tag: Word 2007 Color Scheme Tag: 115019
Can't enable the macros in Word - system says it is but it is NOT
Went on line, followed instructions, but my system says macros are enabled,
but I still get the most annoying message that they are disabled every time I
open a WORD document Tag: Word 2007 Color Scheme Tag: 115016
cycle through embedded excel chart objects in code
I have a doc with several excel object charts.
Can I cycle through these in VBA and change the location of the source file
(excel file)?
I need this so the pair (word and excel file) will work even if I move them
to a different location.
Thansk.
Jesper Tag: Word 2007 Color Scheme Tag: 115014
remove warning when updating linked excel chart-objects
I have a word-document with several charts that are linked to an excel file.
When I open the doc a warning appears asking whether I want to update the
objects.
Can I get rid of this?
Thanks.
Jesper Tag: Word 2007 Color Scheme Tag: 115013
Insert values from Excel at Bookmarks in Word
Hi,
I have a word document (Document1) with five bookmarks. I have an
excel workbook (Workbook1) with three sheets. I want to insert values
from different cells in the excel workbook into the five bookmarks.
The values in the excel workbook are placed in different cells in the
three worksheets. What would the be the code to accomplish this?
I assume the mail-merge option is out because it requires a list. The
data here is scattered across the different worksheets.
Thanks in advance for the help.
Regards,
Raj Tag: Word 2007 Color Scheme Tag: 115004
inserting blank line
I have a template which has a userform for the user to choose which type of
letter.
the form has a dropdown and formfield("text13")
For 2 of the types I hide the dropdown and the formfield.
For the other type when I display the dropdown and formfield, I need to
insert a blank line before my next paragrapgh.
In my macro I populate 1 text field and then need to insert the blank line:
I've tried the insertafter as seen here but to no avail.
Sub NoRefPPD()
ActiveDocument.FormFields("Para2").Result = "Enclosed, please find a copy of
the report stating that you have reached Maximum Medical Improvement from the
" & _
"above-noted injury."
ActiveDocument.Bookmarks("Text13").Range.InsertAfter (Chr(13))
End Sub
How can I insert a blank line or additional carriage return after ("Text13") ?
Thanks,
Bryan Tag: Word 2007 Color Scheme Tag: 115002
Update Links
I have about 5 links in my Word doc all lnked to 5 different excel files.
They are set to update automattically when the document opens. But if some
one changes the excel file it does not reflect it in the document until I
update the links manually by either goin to edit/links then updating them, or
by right-clicking on each and updating them seperatley, or by opening and
closing the document.
But what I want to have is a commandButton that when clicked it updates all
the links in the document. Tag: Word 2007 Color Scheme Tag: 114999
Calling form fields by string-name?
Dear All
The name of my form is "form1". It contains two input fields:
"field_1" and "field_2".
For both files I'd like to have the same action, done in function
"TextFieldName".
Function SetTextField(TextFieldName As String)
form1.<<Name_of_Field_n>>.Font = 0
End Function
What is the syntax to pass a string as a form-name-object?
Kind regards
Oliver
I've been trying with:
- form1("TextFieldName").font = ...
- form1.Item("TextFieldName").font = ...
- form1.Index("TextFieldName").font = ...
.. with no luck... Tag: Word 2007 Color Scheme Tag: 114996
Inserting a Page Number in a Table in a Header
I'm trying to insert a page number field inside a table inside a header.
Basically, I want the text in Cell 1,1 to print, then Cell 1,2 should have
"Page X" in it. Here's what I have so far:
With ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range
'Wipe out header
.Select
Selection.Delete
'Add table
.Tables.Add
Range:=ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range,
NumRows:=1, NumColumns:=2
.Tables(1).Cell(1, 1).Select
Selection.TypeText Text:="Text goes here"
.Tables(1).Cell(1, 2).Select
'Selection.TypeText Text:=
Dim rng As Range
Set rng = .Tables(1).Cell(1, 2).Range
rng.ParagraphFormat.Alignment = wdAlignParagraphRight
rng.Text = "Page "
rng.Collapse wdCollapseEnd
rng.Fields.Add rng, wdFieldPage
Unfortunately, at that last line, I get Run-Time Error 4605: "This command
is not available."
I've narrowed it down to the fact that it's in a table. How can I fix this?
I'm working on Word 2007 12.0.6311.5000.
Thanks! Tag: Word 2007 Color Scheme Tag: 114992
Input on how to generate charts in word from Access data
I need to automatically generate a word document that has a number charts
(approx 17).
If needed I can predefine the properties of each chart (type, axis, title
etc).
The data is in a Access database. Pulling data into a template would be fine
if possible, or anything else that works.
Could you give me some pointers as how to go about this?
Should I export data to an Excel file with predefined charts and then
automatically link these into the word document?
Or should I export values directly into word and use the Graph-object to
display the charts?
I'm very good at Access VBA, moderately good at word-vba.
Thanks for any input.
Jesper Tag: Word 2007 Color Scheme Tag: 114985
how to pause running application
hello,
How to pause an application which is creating an word report?
i want to pause these word report generation and want to resume it after i
restarting the system. The data for word report generation is taking from MS
Access and SQL server. Tag: Word 2007 Color Scheme Tag: 114984
Problem Inserting graph
Hi,
I use the code below which I got from here to insert a line graph, which
works. But shows a bar chart before changing to a line graph which can take
some time to change and seems to be messing things up. So I have place the
following code after it to to pause things to see if it helps.
Dim StartTime
StartTime = Timer
Do While Timer < StartTime + 60
DoEvents ' Yield to other processes.
Loop
While this does seem to help, sometimes, itâ??s a bit slow and takes a bit to
long.
Is there a way of refreshing things so that the change is immediate?
Also do I have â??diag.ChartType = xlLineâ?? in the right place?
I would like to point out I have changed it so it now takes the data from a
file and not a table.
Why does this change the num lock?
Is there anything else I shold know?
Sorry i may have to many questions in one message
Sub Test()
'You need to set a reference to "Microsoft Graph 11.0 Object Library" in
'Tools > References (VBA Editor menu bar).
'Declare some variables:
Dim o_OLE As Word.OLEFormat
Dim diag As Graph.Chart
Dim docCurrent As Document
Dim rngInsertGraph As Range
Dim docSourceData As Document
Dim tblData As Table
'Then, set the variables, like:
Set docCurrent = ActiveDocument
Set docSourceData = Application.Documents.Open("C:\My Documents\test.doc")
Set tblData = docSourceData.Tables(1)
'Inserting graph at beginning of paragraph 2 in document. _
You could use the current selection instead...
Set rngInsertGraph = docCurrent.Content.Paragraphs(2).Range
rngInsertGraph.Collapse wdCollapseStart
rngInsertGraph.InlineShapes.AddOLEObject ClassType:="MSGraph.Chart.8", _
FileName:="", LinkToFile:=False, DisplayAsIcon:=False
Set o_OLE = rngInsertGraph.Paragraphs(1).Range.InlineShapes(1).OLEFormat
o_OLE.DoVerb wdOLEVerbShow
Set diag = o_OLE.Object
'Manipulate the object like this:
With diag
diag.ChartType = xlLine
With .Application.DataSheet
'Assuming row one and column one contain headers _
which means that .Cells(1,1) is empty
'Get header from docSourceData:
.Cells(1, 2).Value = Left(tblData.Cell(1, 2).Range.Text, _
Len(tblData.Cell(1, 2).Range.Text) - 2)
.Cells(1, 3).Value = Left(tblData.Cell(1, 3).Range.Text, _
Len(tblData.Cell(1, 3).Range.Text) - 2)
.Cells(1, 4).Value = Left(tblData.Cell(1, 4).Range.Text, _
Len(tblData.Cell(1, 4).Range.Text) - 2)
.Cells(2, 1).Value = Left(tblData.Cell(2, 1).Range.Text, _
Len(tblData.Cell(2, 1).Range.Text) - 2)
' If you have more than two rows...
' .Cells(3, 1).Value = Left(tblData.Cell(3, 1).Range.Text, _
' Len(tblData.Cell(3, 1).Range.Text) - 2)
' .Cells(4, 1).Value = Left(tblData.Cell(4, 1).Range.Text, _
' Len(tblData.Cell(4, 1).Range.Text) - 1)
.Cells(2, 2).Value = Left(tblData.Cell(2, 2).Range.Text, _
Len(tblData.Cell(2, 2).Range.Text) - 2)
.Cells(2, 3).Value = Left(tblData.Cell(2, 3).Range.Text, _
Len(tblData.Cell(2, 3).Range.Text) - 2)
.Cells(2, 4).Value = Left(tblData.Cell(2, 4).Range.Text, _
Len(tblData.Cell(2, 4).Range.Text) - 2)
' If you have more than two rows...
' .Cells(3, 2).Value = Left(tblData.Cell(3, 2).Range.Text, _
' Len(tblData.Cell(3, 2).Range.Text) - 2)
' .Cells(3, 3).Value = Left(tblData.Cell(3, 3).Range.Text, _
' Len(tblData.Cell(3, 3).Range.Text) - 2)
' .Cells(3, 4).Value = Left(tblData.Cell(3, 4).Range.Text, _
' Len(tblData.Cell(3, 4).Range.Text) - 1)
'Etc.
'By default, a newly inserted chart is 4x4. _
So, if you have 3 columns and only 2 rows, delete extra stuff
.Columns(5).ClearContents
.Rows(3).ClearContents
.Rows(4).ClearContents
End With
'Sample code to manipulate the chart istself
.HasLegend = False
' .Application.PlotBy = xlColumns
' .Width = CentimetersToPoints(15)
' .PlotArea.Width = CentimetersToPoints(8)
' .Axes(xlCategory, xlPrimary).TickLabelSpacing = 10
' .Axes(xlCategory, xlPrimary).TickLabels.Orientation = 90
End With
'And do not forget to destroy the objects:
'Deactivate the graph object
diag.Application.Quit
'Clear objects
Set diag = Nothing
Set o_OLE = Nothing
SendKeys "{ESC}"
docSourceData.Close wdDoNotSaveChanges
docCurrent.Range.InsertAfter "New text inserted after chart was created."
End Sub
--
Rich...
http://www.jadwizracing.co.uk Tag: Word 2007 Color Scheme Tag: 114983
Word 2007 DocVariable losing vbCr on File Close/Open
Hello all
I am storing data from a UserForm in a Word 2007 document in DocVariable
fields. Some docvariables are being loaded from multiline textboxes via code
like:
ActiveDocument.Variables.Add "v1", TextBox1.Text
For test data, assume I type in "a" plus ENTER plus "b" into the text box
(without the double quotes) - so my textbox contains an "a" plus a vbCrLf
plus a "b". After running the above Variables.Add line in my OK_click routine
and closing down the userform, I then run this macro to display the contents
of the docvariable (all Dim statements etc removed to keep it short):
Sub aaa()
v = ActiveDocument.Variables("v1")
For i = 1 To Len(v)
s = s & Asc(Mid(v, i, 1)) & " "
Next
MsgBox s
End Sub
As expected, this displays "97 13 10 98". If I now save the document in
native DOCX or DOCM format, close it, reopen it, and then rerun the same
macro, it will now display "97 10 98". The action of closing and re-opening
the document loses the vbCr (i.e. the ascii 13). This is NOT what happens in
earlier versions of Word. Any ideas on how to stop this? All of the
{docvariable v1} field codes in the document display correctly (i.e. show the
paragraph mark) until you close and reopen the document. After reopening the
document the "a" and the "b" will be on the same line - i.e the paragraph
mark is now missing in the document.
C'ya all
Trevor Tag: Word 2007 Color Scheme Tag: 114977
ReProtect = Reset Forms
Help, I'm using the following code to re-protect form fields in Odd Numbered
Sections. It works great except it is also resetting the form fields. Here
is the code that I am useing. Thanks for your help.
Sub reprotect()
Dim sPassword As String
For Each oSection In ActiveDocument.Sections
'If the section's index / 2 <> 0 (odd) protection needed'
If oSection.Index Mod 2 <> 0 Then
oSection.ProtectedForForms = True
Else
'no protection needed(even)'
oSection.ProtectedForForms = False
End If
Next
If lProtected <> wdNoProtection Then
sPassword = ""
ActiveDocument.Protect Type:=lProtected, NoReset:=True, Password:=""
End If
End Sub
--
Eric the Rookie Tag: Word 2007 Color Scheme Tag: 114971
Editing template with Image to be changed.
I have over 100 documents and I have to change a small image that needs to be
changed.
Is there a way to search a document for the first graphic Object it finds
and replace them with another one? I have some scripting that replaces text,
but I'm not 100% sure how the image part of it would work since I haven't
been able to recover the actual object name.
Thanks Tag: Word 2007 Color Scheme Tag: 114968
Way to print out more then first page
I have a word document that has a Table of Contents that uses hyperlinks. The
user selects the article they would like to view via the TOC and is taken to
the document. from there they click on a button on the page that is to print
out the document currently in view. However some of the documents have
overflown into two or more pages. Is there a way to build a function that the
document runs prior to the user clicking on the TOC so that the function
knows the number of pages assigned to each link in the TOC. That function
then passes the number of pages to the Application.PrintOut method to assure
that all the pages are printed?
The function would have to be smart enough to figure out the pages as this
function would be embedded in a template file for further use by the users. Tag: Word 2007 Color Scheme Tag: 114965
Macro - Subtract one day from current date
Hello,
I have been reading past posts from people who want to auto put a date in
their document that is not currentdate. I have read "WORD Date & Time
Manipulation: Tips & Techniques" document and I tried doing exactly what it
has and I am not getting any closer to my goal. So I think a macro could be
the best bet.
So what I want to do (and I am open to suggestions about how it should be
done), I want to insert a date in a field, text box or whatever works best,
and have the macro subtract one day from the current day(TODAY) so it will
show yesterday's date, in this format "d-MMMM". HELPPP!!!! Tag: Word 2007 Color Scheme Tag: 114964
Creating a Macro that will only print the current page
I am having difficulty with this task. I am unable to record a macro that
will only print one page. I have created a faux macro and edited it to
include the following:
Public Sub PrintCurrentPage()
With Dialogs(wdDialogFilePrint)
.Range = wdPrintCurrentPage
.PrintToFile = False
.Execute
End With
End Sub
but it prints the entire document and not just the current page. Can anyone
help me with this. I am using Outlook 2003 on Windows XP.
Thanks in advance Tag: Word 2007 Color Scheme Tag: 114957
Footer Macro in Word - Section Count
I'm trying to create a macro that can copy the information in the Footer on the first page (section one) to the rest of the footers in the remainnig sections. The macro needs to know how to count the sections and use that number to 'repeat' the copy/paste function. Does that make sense? Can anyone help?
Thanks! Tag: Word 2007 Color Scheme Tag: 114954
Inserting Signature Boxes
Hi there,
I just wondered if there was a way of inserting a number of signature boxes
at the bottom of a letter for a mail merge we are doing?
Idealy I would like to use an input box to ask how many are required and
depending on the answer (anywhere from 2 to 5) I want it to insert this
number of "Signed................. Date................ Print
Name.............." etc. I have tried this numerous ways but im afraid my
lack of knowledge/skills has got the better of me.
Does anyone have any suggestions/ideas?
Thanks very much in advance, Tag: Word 2007 Color Scheme Tag: 114947
Save userform data
Hi,
I have a userform with a lot of data (text boxes, check boxes, option
buttons). When the doc file is saved, these values are lost. Is there any
way to include a subroutine that would save these values to a txt file
(without using doc form fields) and allow the information to be retrieved
when the doc is reopened?
For example: the userform asks for the "Name". On the clicking of a
command button, the active document form field "Name" is set to equal the
userform "Name". However, some of the saves are much more complicated. A
check box could result in a form field being set to the a paragraph in the
code. I don't want to save the paragrahp in the txt file. I want to save
the userform check box value.
Any ideas?
Thank you,
SoCal Rick Tag: Word 2007 Color Scheme Tag: 114929
ContentControlOnExit
I am confounded by the behaviour of the the subject Document Event. I am
trying to use the event to ensure users only enter valid data. I have tried
this method several times in the past only to experience the same trouble.
This morning I entered a DatePicker control titled "Start date," to plain
text controls titled "SSN" and "Number" and a dropdown titled "Gender"
containing two list items "Male" and "Female. After creating the controls I
created the procedure shown below. Everything worked perfectly. I saved
and closed Word several times and the document still worked perfectly. This
afternoon I went to work on this example some more and all of a sudden if I
enter an invaled entry the procedure runs in a continous loop. You would
see this in the Start date CC as the msgbox continously pops up thereby
locking up the form. In the other CCs you can observe the selection flicker
as the procedure continously re-selects the CC text. The only way to stop
it is for the user to physically select the CC.
First I can't figure out why this happens at all, but more confounding is
why it sometimes works and then suddenly stops working. Is this a bug or am
I missing some step that would force the procedure to terminate once the
invalid CC text is selected? Thanks.
Private Sub Document_ContentControlOnExit(ByVal ContentControl As
ContentControl, Cancel As Boolean)
Dim pStr As String
Dim pDate As Date
pStr = ContentControl.Range.Text
pDate = Now
Select Case ContentControl.Title
Case Is = "Start date"
If DateDiff("d", pDate, ContentControl.Range.Text) < 60 Then
MsgBox "Please enter a start date after " & Format(DateAdd("d", 60,
pDate), "MM/dd/yyyy")
ContentControl.Range.Select
End
End If
Case Is = "SSN"
If Not pStr Like "###-##-####" And Not pStr Like "Click here to enter
text." Then
If pStr Like "#########" Then
ContentControl.Range.Text = Mid(pStr, 1, 3) & "-" & Mid(pStr, 4, 2)
& "-" & Mid(pStr, 6, 4)
Else
ContentControl.Range.Select
End
End If
End If
Case Is = "Gender"
If Not pStr Like "Male" And Not pStr Like "Female" Then
ContentControl.Range.Select
End
End If
Case Is = "Number"
If Not IsNumeric(pStr) Or Not Val(pStr) > 0 Or Not Val(pStr) < 150
Then
ContentControl.Range.Select
End
End If
End Select
End Sub Tag: Word 2007 Color Scheme Tag: 114928
Move to next page
Hi,
I have found the following code on here to get to the next page.
MyPage = Selection.Information(wdActiveEndPageNumber)
Selection.GoTo What:=wdGoToPage, Name:=MyPage + 1
But what if there is no next page?
How could i adapt this so that if there is no next page it creates one and
moves to it
--
Rich...
http://www.jadwizracing.co.uk Tag: Word 2007 Color Scheme Tag: 114924
Is lookup possible in Word?
Hi All
I've done quite a bit in VB, but virtually nil in Word VBA, which is why I
need to post this message :0)
Basically my colleague has to fill in a football report and there are
certain areas where he's having to enter duplicate data numerous times.
To try and remove this duplication what I need to be able to do is allow him
to enter 2 team sheets at the top of the doc, ie Home and Away team, and
then in all of the other relevant places in the doc it auto fills in the
player names.
In essence, I need to able to have some kind of lookup/portal control so
that if he types in a field/line on page 1 of the doc then it auto goes into
a designated field on page 12, 30, 54, etc.
Is this possible?
Thanks Tag: Word 2007 Color Scheme Tag: 114918
Numerics in form drop down fields
I want to create a drop-down list using a form field that has numeric
options that can be used in formula fields. It appears that the values
I enter are treated as text and not numeric. Is there a way to make
the drop-down values numeric so I can use the values to perform
calculations? Tag: Word 2007 Color Scheme Tag: 114909
save to two locations in word and powerpoint
I understand there there is a macro
(http://www.gmayor.com/automatically_backup.htm) for word. Can that same
macro be used in powerpoint and excel? I tried and it gives me an error..if
not, anyone know a macro? Tag: Word 2007 Color Scheme Tag: 114908
Can't get document events to trigger
Help! I'm an experienced vba programmer in access, and cannot for the life of
me figure out how to get simple events to trigger in word. All I want is for
a sub to run whenever a doc is opened. I tried Document_Open and
Document_New, I tried creating an AutoExec macro, but whenver I open a test
doc nothing happens. Can someone please tell what the secret is? I've wasted
much too much time on this seemingly ridiculously simple task!! Any help is
appreciated.
Note: I originally put a command button on the doc (via the control
toolbox), which would trigger it's event when the user clicked it. Simple
enough, you would think. That worked on first try, but whenever I closed and
reopened the doc the button no longer worked. After doing some research, it
seems like using the controls from the control toolbox is a no-no. I am
mystified by Word's VBA rules!
Jim B Tag: Word 2007 Color Scheme Tag: 114904
Counting Rows of a table with a twist
I have a document with many tables. I want to have a button or checkbox or
radiobutton located in the upper-right cell of each table so that upon
clicking on it, all of the rows within the table hide, except for the first
row.
If the the rows are hidden, another click of the event-trigger will unhide
them.
So far, I have something like this:
Private Sub BtnHide1_Click()
Dim TableNo As Integer
TableNo = 1
Call CountTablesRowsParas(TableNo)
End Sub
'Identify which table is at stake
Sub CountTablesRowsParas(WhichTable As Integer)
Dim oDoc As Document
Dim oRange As Range
Dim nTables As Long
Dim nRows As Long
Set oDoc = ActiveDocument
Set oRange = oDoc.Range
nTables = oRange.Tables.Count
MsgBox "This document has " & nTables & " table(s)."
If nTables <= 0 Then
MsgBox ("This document does not have tables. Please use the Headline
View of Word to hide lines of text")
Exit Sub
ElseIf nTables > 0 Then
nRows = oRange.Tables(WhichTable).Rows.Count
Call HideRows(nRows)
MsgBox "Table number " & WhichTable & " has " & nRows & " row(s)."
End If
'counting the rows of the table at stake and calling the hide sub
Sub HideRows(howmany As Long)
Dim i As Long
For i = 2 To howmany
ActiveDocument.Tables(1).Rows(i).Range.Font.Hidden = True
Next
End Sub
'executing the hide procedure
What I would like to do is to modify the first sub called "Private Sub
BtnHide1_Click()" so that I don't have to write as many of these as there are
tables in the document.
Is there a way to, upon clicking the event-trigger located in the
upper-right cell of a particular table, identify which table am I on and send
this parameter to "Sub CountTablesRowsParas(WhichTable As Integer)".?
Thank you,
Juan Tag: Word 2007 Color Scheme Tag: 114903
How do i get Word to look at a certain file path for my templates
I just started using MS Office 2007. In the old version of Word, i new how to
program Word to go to a certain file path whenever I wanted to use a
template. I don't know how to change that file path in Word 2007. Any ideas? Tag: Word 2007 Color Scheme Tag: 114894
inser picture
I want to insert a tif image on a new page
I have done this with docs using:
Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "W:\Collective Bargaining Letter.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With
How can I inser a tif image after a section break?
Thanks,
Bryan Tag: Word 2007 Color Scheme Tag: 114890
saving pages of a file into separate files
hello all,
I wrote a code where each individual page of a large file is saved
into separate files. However, I haven=92t been able to consistently copy
the headers and footers accordingly. Any suggestion?
Here is the segment of my code:
For i =3D 1 To j
ActiveDocument.Bookmarks.ShowHidden =3D True
'Select and copy the text to the clipboard
ActiveDocument.Bookmarks("\page").Range.Copy
'Open new document to paste the content of the clipboard into
Documents.Add
Selection.Paste
'Gets rid of possible break that is copied at the end of the
page
Selection.TypeBackspace
ChangeFileOpenDirectory (MyPath & "\PageToFile")
PageNum =3D PageNum + 1
ActiveDocument.SaveAs FileName:=3Dprefix & PageNum & ".doc"
ActiveDocument.Close savechanges:=3DwdDoNotSaveChanges
'Move the selection to the next page in the document
Selection.GoTo What:=3DwdGoToPage, Which:=3DwdGoToNext, Count:=3D1
Next i
thanks in advance,
mm Tag: Word 2007 Color Scheme Tag: 114889
I can't find a way to switch color schemes using VBA in Word 2007. I know
you can apply a theme but i only want the colour scheme.