Search for text box formatted to Layout: In line with text
Hi.
I've managed to set up a macro that hides the content of all text boxes in
my document by searching for each text box and setting the contents' font
colour to white. However, it only seems to find text boxes that haven't been
formatted to 'Layout: In line with text'.
Does anybody know way to search for and edit these text boxes as well as the
others?
Here is the code that I am using:
Sub HideAnswers()
' Find each text box and set it's font colour to white
Dim aShape As Shape
For Each aShape In ActiveDocument.Shapes
If aShape.Type = msoTextBox Then
aShape.Select
Selection.Font.Color = wdColorWhite
End If
Next
End Sub
Any help would be really appreciated.
Cheers,
Dan. Tag: opening word 2007 attachmentts Tag: 110571
embded excel spreadsheet
Hi,
I tried to embed excel spreadsheet into the word template document but when
I try to use macrobutton in this sheet it does not do anything. could
somebody tell me why?
thanks
Peter Tag: opening word 2007 attachmentts Tag: 110570
CALLING EXTERNAL DOCS
Hi.
How could I call external document to open with macro after selecting
macrobutton in userform?
I need to have four slightly different templates of document with
differencies only in number of active substances what will cause to use of
diggerent userforms and different documents.
small difference at the beginnign, big difference at the end.
could somebody help?
Thanks
Peter Tag: opening word 2007 attachmentts Tag: 110569
ActiveDocument - AutoOpen
Good morning,
I am trying to create a macro that will allow me to recall the AutoOpen
function of the current document.
I have been trying the following with no prevail:
From within my Normal.dot file, this one only causes errors.
[code]
Sub Reset_Document()
Application.Run ActiveDocument.ThisModule.ThisProcedure
End Sub
[/code]
and this one does half the job
[code]
Sub Reset_Document()
With ActiveDocument
.Reload
.ResetFormFields
End Sub
[/code]
and this one only errors
[code]
Sub Reset_Document()
With ActiveDocument
.ResetFormFields
AutoOpen()
End Sub
[/code]
Now the middle one causes my fields to be cleared, which is nice; but I have
some Input boxes that appear when the user opens the document and they do not
appear.
So my question is: How do I recall the AutoOpen function of my document from
a Macro stored in another document?
On another note, how do I highlight code? Tag: opening word 2007 attachmentts Tag: 110563
Other groups...
Greetings to all,
Now that I have a 9-5 desk job, I cannot access the groups with he tools I
would like to use. During the last 5 years I was using Outlook Express at
home where I used to work as well. Here at the office I am now stuck with
Lotus Notes. I tried accessing Usenet with Lotus Notes (It does offer
Newsgroup capabilities) and with OE, but I believe the security set up by the
IT people at the company is preventing me from making an NNTP connection. So
I am using the Web Interface.
I am getting accustomed to it. But I noticed that it is called "Word
programming."
Where are the 5 basic VBA groups I am used to
(microsoft.public.word.vba.addins, microsoft.public.word.vba.beginners,
microsoft.public.word.vba.customization, microsoft.public.word.vba.general,
microsoft.public.word.vba.userforms)?
Also, while I was on Google groups, I noticed that there is a group called
"microsoft.public.word.vba". I never saw it with OE.... What is it? Was it
always around but I just never noticed it thinking it was just a prefix, not
an actual group)?
Am I correct in asuming that "Word Programing" is in fact
"microsoft.public.word.vba.general"?
If there is no connection between the Web interface and those 6 groups, how
do people, post to those groups? (Presumebly this means that there is no
connection betwen Word itself and those 6 groups.) Will I have to use Google
to access those groups? Anybody using Google to manage their posts? How is it?
Thanks. Tag: opening word 2007 attachmentts Tag: 110555
pictures and W2007 treatment
After reading Daiya Mitchell's article "Word Doesn't Know What a Page Is," I
wonder if the mailbox treatment that she described (text one one,
headers/footers another, floating graphics on another) is still applicable in
Word 2007? Here's why I ask.
To avoid problems with float over graphics wandering into unwanted places
when reflowing text, I have instead placed images into multi column
borderless tables as in-line. I do this only when I need to simulate wrapped
text. Is this cautionary practice necessary anymore with the new structure of
W2007? I have just gotten the 2007 Office Suite and am not XML literate
enough to know its impact.
Any insights would be appreciated. Tag: opening word 2007 attachmentts Tag: 110553
How to close the template or Document 1
Hi
Someone has very kindly helped with some code which I need to ammend in
order to be complete but I am not sure how to do it.....I have tried many
various possiblities.
First thing that happens when a certain document opens is a form appears
allowing a user to select a template.
This is the code behind one of the buttons on the form.
Private Sub CommandButton1_Click()
Word.Documents.Add Template:="G:\Template\ent_test.dot"
Me.Hide
ThisDocument.Close
Document1.Close
End Sub
This works great and opens a new document based on the template closing the
original document.
This is the code behind the template which fills certain fields with merged
data which works perfectly.
Sub AutoNew()
With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:= _
"C:\ENTMRG.DBF", ConfirmConversions:=False
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute
End With
End Sub
My only problem is, once the template opens and the macro is run, although a
correct document opens, the template or at least a document called Document1
is also open. Ideally, I would like that document to close without saving
changes only leaving the document with the merged data open.
The reason why is it is giving the user to many options for confusion when
closing multiple documents.
I hope you understand what I am asking as it is not easy to explain. Tag: opening word 2007 attachmentts Tag: 110533
Open File on ftp site
Good afternoon --
I want to set up a command button to open a document sitting on our office
ftp site. So, if the file address is ftp://folder/subfolder/document.doc,
can someone help me with a code snippet?
Thanks in advance. Tag: opening word 2007 attachmentts Tag: 110529
Making a check box that will automatically put in check when click
We are making a form that will be filled out on the internet and must have a
check box that will put a check mark into the box when clicked on. The
directions from "help" are not making it happen. The form has been created
and the check boxes added to it, could this be the problem? How to fix?
HELP! Tag: opening word 2007 attachmentts Tag: 110526
Locking Master Document
I need to be able to lock a word master document from VBA. In word from the
outline view when I position the cursor inside the master document and click
the Lock Document icon this works fine but if I record these actions the
macro produced contains the code:
Selection.Range.Subdocuments(1).Locked = Not Selection.Range.Subdocuments( _
1).Locked
If I run this macro I get a message saying the selected member of the
collection does not exist.
Anyone know how to lock a master document from VBA? Tag: opening word 2007 attachmentts Tag: 110523
Displaying Conditional Content in Word 2007
I'm looking for recommendations on creating and managing conditional content
in Word. Examples may be:
1. I have a resume that has slightly different content for different
industries' jobs I'm applying for. For example, in my last job in the
"Experience" section, I may want to put three bullet points with text for my
"manufacturing industry" resume and two of the same bullets of from the first
list and another new bullet point (also hiding one of the bullet points from
the first resume) for my "financial industry" resume. If I want to add a 3rd
industry to apply for, such as the medical industry, maybe I just want to
replace certain words in an existing financial industry bullet, for example,
replacing the word "Sarbanes-Oxley" with "HIPAA".
2. I am creating a course on a subject. The end result will be 3 seperate
documents - Instructor Guide, Participant Guide and Classroom Logistics
Guide. The Instructor Guide will include the Participant Guide and Classroom
Logistics Guide, as well as instructor delivery notes (in seperate blocks of
content, like "Say This", "Common Questions from Participants", "How to Run
this Activity"). The Classroom Logistics Guide will just be one or two sheets
that may need to be saved seperately so it can be sent to another person if
they are arranging part of the classroom logistics.
Rather than perform a huge amount of copy/paste/delete and try to keep all
the data current, I'm looking to just keep all this information in a single
document - any outputted documents will be the result of editing the single
document template.
I've read some about XML and XSLT, but I don't know if they are what I'm
looking for, because it appears that XSLT will reformat the document, when
all I want is content switched out or removed/added based on content type -
all formatting should stay as is. Is this something I can just tag certain
content with an XML tag and then run a VBA routine against to remove that tag
from the view of the rest of the document? The "Memo" and "Resume" XML
samples for Word on MSDN weren't helpful. Bill Coan has a good example I
looked at on wordsite.com, but his is all about formating for HTML (but the
key idea is there as to what I'm looking for).
I've also considered using "hidden text" inside of a Content Control and
then just using VBA to hide all parts I don't need via the Control's tag, but
that's just a binary choice of include/don't include and I need conditional
logic.
Any help in this regard is deeply appreciated - pointers, samples, real
world examples, a smack in the face... :)
DD Tag: opening word 2007 attachmentts Tag: 110514
trust macros in Word 2007
Is there a way I can define Word 2007 .docm files to be trusted when
coworkers download them from our Company intranet and then open them?
A solution that doesn't require the user to allow macros each time would be
greatly appreciated. Tag: opening word 2007 attachmentts Tag: 110512
How to get a user commandbar to always appear
I've found some posts from people who can't get rid of their command bars but
my problem is the opposite.
In Excel to get a custom commandbar to run at startup I just use:
Private Sub Workbook_Open()
CreateTheComandBar
End Sub
It can be in any template and if it's in Personal.xls then it'll appear in
all my workbooks.
How do I do the same in Word ?
Private Sub Document_Open()
CreateTheComandBar
End Sub
...in Normal.dot doesn't work. The same thing in Document_New works for
subsequent new documents but the bar ain't there when I start word.
Running "CreateTheComandBar" from the VBA editor works just fine but if I
close and restart Word it's gone.
Why are Word and Excel *still* so different in their behavior after so many
wonderful years of co-existence ?
--
David M
WinXP - Office2003 (Italian) Tag: opening word 2007 attachmentts Tag: 110500
Reformatting text
I receive a report in Word and need to export to an Access database. The
problem is the record format isn't in a delimited format. Each record in
Word has the following format:
fied1 text (tab) field2 text(paragraph)
field3 text (tab) field4 text(paragraph)
field5(paragraph)
paragraph
number
paragraph
Next Record
I would like to create a macro or something so the format for each record is
something like: text, text, text, text, number so I can save as txt and
import into Access. Tag: opening word 2007 attachmentts Tag: 110496
How to: Block user input temporarily?
Hi,
If I am manipulating text in a word document using e.g. selection
property, I might want to keep the user from inadvertantly typing over
my temporary selection by blocking user input. In Excel I could set
Interactive = false I gather - is there an equivalent setting for
Word?
Sincerely,
Anders Tag: opening word 2007 attachmentts Tag: 110492
Use of Macro in combination with auto text and comment field
Hi,
What I want to do is create a macro button so that I can automatically
insert a comment field with some auto text in it. It works fine if I do it
manually â?? I can insert a comment into the text and then select the comment
field and place auto text into this. However, when I try to do this procedure
using a macro I get Run time error 5941 â??The requested member of the
collection does not existâ?? Any ideas? I am using Word 2007.
Thanks David Tag: opening word 2007 attachmentts Tag: 110478
Avoiding the Find/Replace dialog in Word 2003
This is a question related to Word 2003 and VBA
I posed this question in an earlier thread, but it was needlessly
complicated and wordy. Here's a clearer way of formulating my question,
perhaps. I hope I'm not breaking any good netizen conventions here.
This is the previous thread:
If you use a newsreader:
news://msnews.microsoft.com:119/eonojSFcIHA.1960@TK2MSFTNGP02.phx.gbl
If you use a browser:
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.word.vba.general&tid=f3baadfe-daeb-4809-9368-f0d5981d8cac&cat=en_US_eb67b351-9403-4888-a42c-b2b58efec0aa&lang=en&cr=US&sloc=en-us&m=1&p=1
Right now, I have a routine that, in part, finds a medical record number
at the top of a document and creates an autocorrect entry for it. I put
it together with macro record and some hints from this forum. The way it
works is that the cursor jumps to the top of the document, finds the
words "Medical Record Number", selects the medical record number, which
is located just to the right, and assigns it to an autocorrect entry MRN.
I'd like to do that without relying on the dialog box, which causes
things to jump around. Assume my cursor is in section 2 and I want it to
stay that way at the end of the macro's run. How would I do that?
Here is the sample code:
Sub MyDemo()
'
' go to top of section
'
Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst, Count:=1,
Name:=""
'
' find medical record number
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Medical Record Number: "
.Forward = True
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdWord, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
'
'Assign to Autocorrect entry mrn
'
AutoCorrect.Entries.Add Name:="mrn", Value:=Selection.Text
Selection.EndKey Unit:=wdLine
End Sub
Regards,
Alan Tag: opening word 2007 attachmentts Tag: 110474
I need a super duper mail merge macro created. Please help
Is there a way to create a template for a word document to have certain
fields pre-populated with form fields and then create a macro to take the
necessity for a user to have to open Mail Merge wizzard and start locating
the data source etc?
Deeper.....
We run our in house software and we can press a 'Letter' button which
creates a .dbf file which is automatically saved in the root of the users C
drive. If they have created this .dbf file, it means they are going to send
a letter to the person who was on the form they were looking at before
clicking the 'Letter' button.
Now, just assuming that the only fields in the dbf file were
first name
last name
address
I would want the user to open there template document (not saved in the C
drive) which would already have the first name, last name and address form
fields in the correct place of the template.
This is when I would like the user to be able to press a form button or
whatever that will then automatically point the fileds to the corresponding
fields in the .dbf field so that our users do not have to try and use the
Mail Merge wizard. They WILL NOT use the Mail Merge wizard as they are
scared of computers.
I know this may be complex or even impossible, but if it can be done, you
will forever be deemed a hero. If it can't be done, other suggestions are
welcome.
Thanks in advance
Malcolm Tag: opening word 2007 attachmentts Tag: 110473
drag and backspace
When I drag the mouse to select some sentences and press 'backspace' to
delete them, it does not delete. It used to do this but it's not working
anymore. Only with Microsoft Word. Others works fine. Tag: opening word 2007 attachmentts Tag: 110470
2 spaces to 1 space in Word 2003.
I have been using a macro at work to take all double spacing after
periods, colons, etc, out of a document and replace them with double
spaces. This macro works on the entire document.
The document is broken into three sections, as defined by the menu items
INSERT>BREAK>CONTINUOUS. I have been trying to figure out how it can
be made to work this magic on only section 2.
This macro is mostly based on one I found in a Word website, and the
proper credit is given in the comment section.
Here is the macro. Any assistance would be very much appreciated.
Sub SingleSpace()
'
'<alt><ctrl><5>
' Changes 2 spaces after periods and colons
' to 1 space in conformity with our hospital
' guidelines.
' Macro modified by Alan Stancliff, based on macro
' copied from Allen Wyatt's Word Tips
'
http://wordtips.vitalnews.com/Pages/T1497_An_Automatic_Two_Spaces_After_a_Period.html
' ******************************
'
Selection.Find.ClearFormatting
'Selection.Find.ClearFormatting.Section (2)
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([.\?\!\:]) {1,}"
.Replacement.Text = "\1 "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Application.Run MacroName:="FixFindBox"
End Sub
Regards,
Alan Stancliff Tag: opening word 2007 attachmentts Tag: 110469
Persistent toolbar .... how irritating
This seems so trivial but it isn't to me. I have a Word doc which when
opened, shows the 'Control Toolbox' toolbar as well as a small dialog box
that allows me to exit 'Design Mode'. I don't want these items to appear so I
close the latter and I turn the former off at View/toolbars/Control. I then
save the document.
When I then re-open the doc, the same two items re-appear. Why? It doesn't
happen with other documents.
TIA ... Greg Tag: opening word 2007 attachmentts Tag: 110466
VBA code to delete a page in a Word doc
Hi,
I am using Word 2003. May I ask how to write a VBA code to delete a
certain page in a Word document? Thank you.
Mike Tag: opening word 2007 attachmentts Tag: 110458
Word Count - But not all of them!
Hi,
Is it possible to use the word count feature in Office 2007 (and hopefully
in Word 2003) to count the words in specific pages in a document?
I don't want to include the title page or appendices.
Thank you,
Pete Tag: opening word 2007 attachmentts Tag: 110455
Write text in table within textbox placed in pagefooter
Hi
I have a problem with a table/texbox object placed in pagefooter. Se
the
description and code here:
'-------------------------------------------------------------------------
' WANT: Replace existing text with new text - format it - in the
pagefooter,
' and the text shall be place in a table there is place in a
textbox
' (there are already added a textbox and inside this a table:
' one row and one coloum).
' COMMENT:
' It works fine when the texbox and table are placed on the
page
' PROBLEM:
' It can't find the shape in pagefooter, and I don't know how to
get it.
' (it shall be a shape and not at frame)
'-------------------------------------------------------------------------
Sub ReplaceText_TableTextbox()
Dim txt_adress As Range
With ActiveDocument
Set txt_adress = .Shapes(1).TextFrame.TextRange
txt_adress.Tables(1).Cell(1, 1).Range.Delete
txt_adress.Tables(1).Cell(1, 1).Range = "This is the first line"
txt_adress.Tables(1).Cell(1, 1).Range.InsertParagraphAfter
txt_adress.Tables(1).Cell(1, 1).Range.InsertAfter "This is the
second line"
txt_adress.Tables(1).Cell(1, 1).Range.InsertParagraphAfter
txt_adress.Tables(1).Cell(1, 1).Range.InsertAfter "This is the last
line"
'Line 1: Bold and spaceafter 10
txt_adress.Paragraphs(1).Range.Bold = True
txt_adress.Paragraphs(1).Range.ParagraphFormat.SpaceAfter = 10
'Line 2: Font size 16
txt_adress.Paragraphs(2).Range.Font.Size = 16
End With
End Sub Tag: opening word 2007 attachmentts Tag: 110450
How highlighting all found items with a macro?
Hello. The Dialog Box of "Find and Replace" (Tab "Find") including the
field with the text "Highlight all items found in...". I need to
select all found words with help macro but I not know how I do it. I
wrote code of searching and highlighting next item but not all items:
With Selection.Find
.ClearFormatting
.Text = Selection.Text
.Replacement.ClearFormatting
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.Execute
End With
How highlighting all found items? Thank you very much. Tag: opening word 2007 attachmentts Tag: 110446
Automatically Lock Document
Hi,
Is it possible to automatically lock a document when opening. I have a
document with form fields. When certain users open the document I want the
form fields to be locked so they will only be able to enter text in the form
field. I can't rely on the user to lock the document. I can't save the
document with it locked because other users may need to check the document
out and edit it.
Any suggestions are welcome.
Thanks,
Mickey Tag: opening word 2007 attachmentts Tag: 110438
how do I insert music file in word document
when I open a word document I want a music file to start playing. Can I do
this? Tag: opening word 2007 attachmentts Tag: 110435
Creating a Find and Replace Macro in Powerpoint
I'd like to create a Find and Replace Macro in Powerpoint that I can
use each day on a different Powerpoint file.
I'm very inexperienced at VBA. However, I was able to use the macro
recorder in MS Word to record a find and replace macro, which I placed
into its own template document, which covers over a hundred items.
Talk about the timesaver of the century.
I also have to edit Powerpoint documents. My edits include text in
textboxes in the slide as well as note pages.
1. Since Powerpoint doesn't have a macro recorder, could I copy the
text below that is used in MS Word into Powerpoint?
2. How would I save it to be available over time (since I edit
documents everyday)?
I recognize that this question is probably very basic for the talent I
see here, but it saves me considerable time doing edits that a
computer can handle in seconds. Thanks.
Jay
VBA is my friend (VBAimf)
Sub Godtest()
'
' God test Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "god"
.Replacement.Text = "God"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub Tag: opening word 2007 attachmentts Tag: 110433
Replace Title Case Function with Macro?
I use Format > Change Case > Title Case quite frequently. However, it is a
pain to have to change all the short words (e.g., the, a, of) back to lower
case.
There is a macro that takes care of that (shown below). I was wondering if I
should replace Word's Change Case function with this macro. Any downsides to
doing that? I've never written my own macro before and all previous macro
work was "step by step" instructions I followed.
If I replace Word's Change Case function with this macro, can someone pls
let me know how I would go about doing it? If I didn't replace the Word
function, how would I set up using this macro?
Using Word 2003 on standalone PC (XP).
Any insights much appreciated.
Here's the macro:
Intelligent Title Case, taken from Allen Wyatt's Word Tips (on-line):
Sub TitleCase()
Dim lclist As String
Dim wrd As Integer
Dim sTest As String
' list of lowercase words, surrounded by spaces
lclist = " of the by to this is from a "
Selection.Range.Case = wdTitleWord
For wrd = 2 To Selection.Range.Words.Count
sTest = Trim(Selection.Range.Words(wrd))
sTest = " " & LCase(sTest) & " "
If InStr(lclist, sTest) Then
Selection.Range.Words(wrd).Case = wdLowerCase
End If
Next wrd
End Sub Tag: opening word 2007 attachmentts Tag: 110431
In Word 2003, a macro that reads screen size and cursor position
Is it possible for a macro to be written that can tell how many lines
are on the screen and which line the cursor is on when the macro runs?
Optionally, I would like to put these into message boxes.
I'm trying to figure something out.
Regards,
Alan Tag: opening word 2007 attachmentts Tag: 110411
How do I put this into a Footer
I would like to insert the UserName FormField into footer programmatically.
this code works but can i get it into a footer?
Selection.Collapse Direction:=wdCollapseStart
Set myField = ActiveDocument.Fields.Add(Range:=Selection.Range, _
Type:=wdFieldUserName) Tag: opening word 2007 attachmentts Tag: 110389
Opening a web page using VB
I have written a script to check if people are opening word documents from
email. All it really does is check the path, if it is in the temp directory
it ask them if they want to save the document to the document managment
system. We recently changed our DM to a web based system. With this I was
trying to modify my script to save to the new dm. All I really need to do is
have the script open a .asp web page that has the document path in the url. I
can format the url I just can't get VBA to open a web page. Not even
google.com. I looked all over the web ie.. googled it, microsoft.com, and the
ms vip pages without any luck. I was wondering if anybody knew how to do
this. Just so you know we use word 2003. Tag: opening word 2007 attachmentts Tag: 110384
Copying Rows with Form Fields
Iâ??m working in Word 2003. Iâ??m creating a template with a table and form
fields. The table make up is this:
1st row has 4 columns
Date: (text in column 1) â?? form field (column 2) â?? Client Name: (text in
column 3) â?? form field (column 4)
2nd row has 4 columns:
Referred To: (text in column 1) â?? form field (column 2) â?? Follow-Up Date:
(text in column 3) â?? form field (column 4)
3rd row as 1 column:
Comments: form field
I would like to attach an on exit macro to the Comments form field that asks
the user if they would like to add another client. If they click on Yes, the
document would unlock and all three rows are copied with the form fields â??
however, the form fields need to be blank. Once copied the template would
lock again.
The user may need to do this many times; add clients.
Any help you can provide is appreciated. Thanks
--
Jamie Tag: opening word 2007 attachmentts Tag: 110381
Help on small macro that won't run
Hi, everyone!
Iâ??m not a developer or professional programmer, just a budding amateur one
at best, wanting to learn more. (I am familiar with basic programming
concepts.) In trying to improve our lives here in Word, I searched for and
found the following code in a post in this discussion group and thought I'd
try it out. It would do exactly what we need, but the procedure doesnâ??t run
after being copied into a NewMacros module. Can anyone please help me, or
set me in the right direction to figure out why it wonâ??t run? I get no error
messages.
We are using Word 2003 (11.8202.8132) SP2.
Any help or any feedback at all on this would be very very very appreciated.
Thank you!
-Lynne
Hereâ??s the code:
Sub FindAndUnderlineTextInQuotes()
'Underlines text exclusive of the quotes marks
Set oRng = ActiveDocument.Content
With oRng.Find
.ClearFormatting
.Text = """<*>"""
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
Do While .Execute
If oRng.Find.Found = True Then
With oRng
.MoveEnd Unit:=wdCharacter, Count:=-1
.MoveStart Unit:=wdCharacter, Count:=1
.Font.Underline = True
.Collapse wdCollapseEnd
End With
End If
Loop
End With
End Sub Tag: opening word 2007 attachmentts Tag: 110377
VBA-Referenceing a Text Field in Active Document
I created a Command Button in a form to send an email from Visual Basic by
following the instructions found here. http://support.microsoft.com/kb/161833
I want to use this to send a short "Order Notice" message to people. I need
to have the Message.Text to only show a unique order name and number for each
message sent.
How can I have the data from a specific Text Form Field on my form
automatically fill in the Message.Text field of my VBA Send Email button? Tag: opening word 2007 attachmentts Tag: 110369
setting 2 different style on same line
I'm automating a Word report with Access. How can I set 2 different style on
a single line of text. Ex:
Enterprise: Name of enterprise
"Enterprise:" sould be in style1 and "name of enterprise" in style 2
.TypeText Text:="Enterprise:" & vbTab & rst!EnterpName
Merci ! Tag: opening word 2007 attachmentts Tag: 110365
Macro to extract headings
I need a macro that opens all of the word documents in specific folder,
extracts the document headings (what you see in the outline view) and pastes
all of the headings into a new document. I have a macro that extracts the
headings (see below).
The problem is, I have to run this macro on each file individually and it
puts the headings in a separate document for each file. I would like to have
one document with all of the headings from all of the files, one right after
each other. Iâ??ve never been able to figure out how to write macros that run
through all the files in a folder. If you have any suggestions, I would
really appreciate your help. Thank you.
Sub PrintHeadings()
' Creates a new document with Heading XX
' style paragraphs only from active document.
' User prompted for max level XX.
Dim para As Paragraph, rng As Range
Dim DocA As Document, DocB As Document
Dim iLevel As Integer, iMaxLevel As Integer
' Ask for max level
iMaxLevel = InputBox("Enter maximum level for Heading style.")
If iMaxLevel = 0 Then Exit Sub
StatusBar = "Printing headings. Please wait..."
Set DocA = ActiveDocument
' Create new document
Set DocB = Word.Documents.Add(DocA.AttachedTemplate.Name)
' Set extra wide page margins
With DocB.PageSetup
.TopMargin = InchesToPoints(0.25)
.BottomMargin = InchesToPoints(0.25)
.LeftMargin = InchesToPoints(0.25)
.RightMargin = InchesToPoints(0.25)
End With
Set rng = DocB.Range
For Each para In DocA.Paragraphs
DoEvents
iLevel = 0
' Check for Heading style
If para.Format.Style Like "Heading [0-9]" Then
iLevel = Val(Mid(para.Format.Style, 8))
' Check for acceptable level
If iLevel > 0 And iLevel <= iMaxLevel Then
rng.Collapse wdCollapseEnd
rng.Text = String(iLevel - 1, vbTab) & _
Format(iLevel) & ") " & para.Range.Text
End If
End If
Next para
' Delete any annoying page breaks
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^m"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll
' Tell user when done
MsgBox "Done creating new document with headings only."
End Sub Tag: opening word 2007 attachmentts Tag: 110361
Use Text Formulas in Word Fields
Data:
FieldName="YYYY.MM.DD_AnyName.doc"
The Main objetive is create a field that read the doc's FieldName property
and write the value "DD.MM.YYYY or "YYYY.MM.DD".
In Excel we use the Text Formula "MID", which is present in WORD VBA.
I don´t know how to reach it.
Could you help me? Tag: opening word 2007 attachmentts Tag: 110358
About the unformatted paste
Can the "paste--paste special--unformatted paste" operation be excuted only
by a single shortcut key combination? Any macro or other programe for this? Tag: opening word 2007 attachmentts Tag: 110353
Changing format of data assigned to DocVariable
Is there any way of changing the format of the data in a DocVariable?
I have the following code emulates what I have in an Access project where I
copy some data from an Access form to DocVariables in a Word document. I want
to be able to apply formatting to it such as bold font but can't find the
right code to do so.
Dim strMyData as string
strMyData = "My test text"
ActiveDocument.Variables("TestFont") = strMyData
ActiveDocument.Fields.Update
Any help will be greatly appreciated.
--
Regards,
OssieMac Tag: opening word 2007 attachmentts Tag: 110341
Generating Documents on the Fly
I am looking for a way to extract certain sections out of one very long
document to generate a seperate document based on answers the user will give
to questions when the document is first opened. So basically I am trying to
generate a document that is tailored to the users needs. Any help or
suggestions would be greatly appreciated.
Thanks Tag: opening word 2007 attachmentts Tag: 110337
Table of Contents Question
I'm trying to generate a TOC with 2 levels (from Heading Styles), however I
don't want page numbers appearing for level 1. Right now the Code looks like
this { TOC \o "1-2" \h\z\u } and it is generating two levels with page
numbers for each level. I tried to look this up in Word's Help area and it
says to use \n if you don't want page numbers, however, when using this it
takes out page numbers entirely. I want page numbers for level 2 but not for
level 1. Can anyone tell me how to specify that? Also, I've tried to find a
list on websites and in the Word help feature that delineates switches that
are TOC specific and that gives examples of what the switch does and examples
of the exact use of them - haven't had much luck there. Any tips pointing me
in the right direction would be appreciated. Thanks in advance. Tag: opening word 2007 attachmentts Tag: 110333
mergefield
hi
how do I do mergefield with =not for more than one field?
e.g. {IF{mergefield "ClientID" } =NOT "1234"
But how do I do in, ie
IF ClientID NOT = 1234 or 5678 or 0987
thanks in advance Tag: opening word 2007 attachmentts Tag: 110329
Search all the characters then get range for some of them
How do I programmatially search all the characters in a word document, then
get Range for some of them so I can change font, etc? I hate to call
Document.Characters because it will take forever. But if I call
Document.Range(ref 1, ref missing) to get all the text, then how do I know
the positions of some of the text since the document may contain
non-printable characters. For instance, I want to search for "Hello world"
in a document, set the text font color to red. Any help will be greatly
appreciated. Tag: opening word 2007 attachmentts Tag: 110328
Populating Content Controls with VBA
Something that really seems to be missing with content controls is the
ability to easily dump info into them programmatically, because of the
necessity to refer to them numerically, rather than by a unique value (like
Title). Is there a simple way to use SelectContentControlsByName (or Tag) to
identify the content control in which you wish to change the text value? The
big issue with referencing content controls by number is that if one content
control in a document is deleted, it effectively re-numbers the rest and
causes all kinds of issues...
Thanks :-) Tag: opening word 2007 attachmentts Tag: 110323
Disabling "next cell" in a table
I have a table divided into protected and unprotected sections. In the
unprotected sections, when the user tabs, a new line is created (as though
it were the end of the table). I want to disable the "next cell" function in
these cases, or otherwise prevent the creation of a new row, or force
navigation to the next form field/section. Any suggestions?
Thanks. Tag: opening word 2007 attachmentts Tag: 110320
Table formatting question
Tony Jollans wrote the following macro to help me with renaming the style in
the tables in my documents. It works great except for the existing formatting
is lost. After it runs everything is right justified. Is there a way to
modify this to keep the existing formatting? So words that are centered stay
centered; words that are left justified stay left justified and words that
are right justified stay right justified.
Set oDoc = Word.ActiveDocument
Selection.GoTo what:=wdGoToPage, _
which:=wdGoToAbsolute, Count:=2
For Each T In ActiveDocument.Tables
For Each P In T.Range.Paragraphs
If P.Style = "Normal" Then P.Style = "tNormal"
Next P, T
Selection.HomeKey wdStory Tag: opening word 2007 attachmentts Tag: 110318
find and replace a font change
How do you find a font change? I have records where the first half of
the line is bold and the second is regular font. The last letter of
the bold part would have to be found using a wildcard but the first
character of the regular font is always a space. I would then like to
change the space to a line break. Thanks! Tag: opening word 2007 attachmentts Tag: 110317
Sort range in table
I have a macro creating a document with a table containing multiple header
rows. I want to sort on the other rows. To exclude the header rows, I define
and then select a range containing these other rows. But when I try to sort
the selection I get a message that the document is protected (which it's
not). Here's the error:
"Run-time error 4605: This method or property is not available because the
document is a protected document."
See code below. The Selection.Sort statement is the highlighted error.
Any idea why? Or, is there a better way to sort a range in a table? (I've
tried just sorting with a range, same result.)
Here's the code:
With ActiveDocument
Set sortRange = Range(Start:=.Tables(1).Rows(7).Range.Start, _
End:=.Tables(1).Rows.Last.Range.End)
sortRange.Select
Selection.Sort ExcludeHeader:=False, FieldNumber:="Column 2", _
SortFieldType:=wdSortFieldAlphaNumeric, _
SortOrder:=wd SortOrderDescending, _
FieldNumber2:="Column 1", _
SortFieldType2:=wdSortFieldNumeric, _
SortOrder2:=wd SortOrderAscending
End With Tag: opening word 2007 attachmentts Tag: 110315
Auto generate serial no and saving addres
I want to assign a serial number to a form when I open the template Form.dot
The serial value shall increase one each time the template Form.doc is
opened by anyone with access to the forms template folder.
I would like the serial number to show up in the header of the Form.
Then I would like to save the Fom.doc as Formâ??serial numberâ??.doc in a
predefined folder for this type of forms.
Any subsequent editing and saving of say Form123.doc shall be overwriting
the existing Form123.doc
Where do I find a description of this kind of functionality?
Thanks in advance
Jorgen Tag: opening word 2007 attachmentts Tag: 110312
Using Office word 2003, how do I open an attahment that is office word 2007?