How to delete pages in MailMerge
Hi-
A week ago, I posted a question that was not successfully answered, so I'll
change my approach and rephrase it.
I have a rather long document that has many fields that are filled in by a
mailmerge. (MERGEFIELDs and DOCVARIABLEs gotten from several user forms,
where the user fills in OptionBoxs, CheckBoxs and TextBoxes).
MailMerge will generate the entire document, but if a certain question is
not answered, I want to delete some pages. If I can set up bookmarks around
these pages, can a macro be automatically run, and if the DOCVARIABLE is "Y",
then delete from BookmarkA to BookmarkB?
Alternatively, is there a better way of doing this?
Thanks,
Marty Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62552
VBA copy and paste
I am working on an application using Word 2003. I am familar with VBA using
Excel and Access, but not with Word.
The application I am working on is a word doc that reads data in from a
database. It can be any number of pages long and each page will be in the
exact same format (consisting of tables, labels and text boxes). What I need
to be able to do is write a macro that on can copy and paste the first page
on to other pages, depending on how many are required (this will be done on
startup).
Can anyone help?
Thanks
Darach Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62549
Renumbering superscript notes?
I'm wondering if it's possible to create a macro that will renumber all the
occurrances of superscipt consecutively--even if they're not using the
endnote or footnote function?
The reason for the last part is that I currently use a macro that unembeds
the notes and changes the note numbers to superscript. This way I can move or
renumber a note manually without deleting the corresponding text of the note.
However, it would be a great help if I could set up a macro that would, after
I'm finishing editing, go through the document and renumber all the notes
consecutively in case there's one that was missing, out-of-sequence, etc. Is
this even feasible?
Thanks in advance!
~Carrie Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62544
Restoring bookmark in header/footer
Restoring a bookmark after changing its contents is a snap in the main
story of the document with ActiveDocument.Bookmarks.Add. Not so in
headers/footers. What's the secret there? Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62543
formattedtext is not a reference error
I'm automating Word2003 in VB.Net. I'm using late binding.
I want to put another document's content into the selected area of the
active document, without loosing its formatting.
I'm getting a 'formattedtext is not a reference property' error with the
following code
... Selection.FormattedText = doc.Content.FormattedText ...
If this is a bug, does someone know another statement to achieve the same
result.
I'd like not to use clipboard.
--
thanks, gloeng Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62537
The below macro will not stop at the end
Hello from Steved
How do I please put a argument in the below macro so that
when it gets to the bottom off the document it ends as at
the moment when it reaches the end it starts deleting
everything above until it deletes it all.
Thankyou.
Sub RaceDictionary()
Dim i As Long, pararange As Range
For i = 1 To ActiveDocument.Paragraphs.Count
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "'"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^$^$^$"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^$^$^$"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=3,
Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "\(*by"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=3,
Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:="= "
Selection.EndKey Unit:=wdLine
Selection.TypeBackspace
Selection.TypeText Text:=", "
Selection.Find.ClearFormatting
With Selection.Find
.Text = "*$"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find.Font
.Size = 30
.Bold = True
End With
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Next i
End Sub Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62534
The below macro will not stop at the end
Hello from Steved
How do I please put a argument in the below macroso that
when it gets to the bottom off the documentit ends as at
the moment when it reaches the end it starts deleting
everything above.
Thankyou.
Sub RaceDictionary()
Dim i As Long, pararange As Range
For i = 1 To ActiveDocument.Paragraphs.Count
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "'"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^$^$^$"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^$^$^$"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=3,
Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "\(*by"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=3,
Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:="= "
Selection.EndKey Unit:=wdLine
Selection.TypeBackspace
Selection.TypeText Text:=", "
Selection.Find.ClearFormatting
With Selection.Find
.Text = "*$"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Extend
Selection.Find.ClearFormatting
With Selection.Find.Font
.Size = 30
.Bold = True
End With
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Next i
End Sub Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62533
Opening a Goldmine email message from Word (using VBA)
I need to use VBA from Word to open a new Goldmine v.6.5 email message programmatically, and hopefully even go a step further and
attach a file or 2 to the new message. I'm not seeing much talk of VBA in the Goldmine forums so I'm kinda worried about now. I
really need this to happen. Can anybody help? I'm flexible and willing to give almost anything a shot. It is starting to appear that
Goldmine doesn't work and play well with others.
Thanks in advance.
--
RMC,CPA Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62530
How to make doc's FullName into an AutoText entry without first inserting it into document
This macro works fine. It temporarily Inserts Fullname of the active
document into the document and makes that string an AutoText entry
called MyDocName, which is used later by another macro to reactivate
this document from another document. This enables me to return
instantly to this document without having to open the Window menu or
scroll through the open documents. But I wonder if there is a more
efficient way of doing it, so that the active document's FullName
doesn't actually have to be inserted into the document as a range, but
rather the FullName becomes an AutoText entry in one step. It seems
that would make the macro a little faster.
Any ideas? Thanks.
Larry
.
Sub DocFullNameStore()
Application.ScreenUpdating = False
Dim X As Long, Y As Long
Dim r As Range
X = ActiveDocument.Range.End - 1
ActiveDocument.Range.InsertAfter ActiveDocument.FullName
Y = ActiveDocument.Range.End - 1
Set r = ActiveDocument.Range(Start:=X, End:=Y)
NormalTemplate.AutoTextEntries.Add Name:="MyDocFullName", Range:=r
r.Delete
End Sub Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62528
Problems deleting tollbar
'I want to make a new toolbar, and delete it. Problem is that it seems to be
deleted ,but
'every time I restart word it is back. If I run Sub createmytoolbar() 6
times it gives me 6
'toolbars after restart of Word ! The only way I can kill them is to delete
normal.dot!
'In word200, normal.dot i have created this
Sub createmytoolbar()
Application.CustomizationContext = NormalTemplate
Dim cBar As CommandBar
For Each cBar In Application.CommandBars 'ActiveDocument.CommandBars
If cBar.Name = "Mine" Then
MsgBox "Mine is there"
cBar.Delete
End
End If
Next cBar
MsgBox "We must make Mine!"
Call createmine
End Sub
Sub createmine()
MsgBox "Then iI have a routine for creating and it seems to work"
' routine
End Sub
What am I doing wrong??
arne Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62525
.dot files get corrupted w/time, so iwhy not use Vb.net w/automati
I have found that template (.dot) files eventually get corrupted, and I have
to create new ones in which I re-create all my forms and macros.
Methinks it'd be a better idea for me to program all the macros and forms in
Vb.net, and to use (what I think is called) "automation" to manipulate Word's
built in functioning.
Am I missing something? Or is my perception "right"?
Any thoughts on this would be most welcome and appreciated.
Marc Hankin Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62523
How do I create a button in a word template that will run a macro
I Have four fields that need to be updated when the template is opened and I
have recorded a macro
Selection.WholeStory
Selection.Fields.Update
Selection.HomeKey
Now I want to display a button that the user can click to run this macro so
he can update the fields.
is it also possible to print the pages individualy to individual pdf files
via a macro to be attached to an email later?
Thanks Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62520
Formatting dates
Hi
I want to use VBA to rename some files with a date. Eg
for 30 Jan 2005 one file is renamed to "EN300105.txt" (eg
ddmmyy.txt)
I have used the following - which works, but actually
renames the file "EN3012005.txt" :
(eg it shortens the ddmmyy format - removes the 0 from
month, etc)
strDay = Format(Day(Now), dd)
strMonth = Format(Month(Now), mm)
strYear = Format(Year(Now), yy)
ActiveDocument.SaveAs FileName:="c:\temp\EN" & strDay &
strMonth & strYear & ".txt",
How can this be changed such that it is
renamed "EN301205.txt"
Thanks
Mat Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62510
Word 2003 customised toolbar
I have a template which has an attached toolbar.
When a document is first created from the template, some of the
toolbar buttons are enabled and some are not.
When the buttons are used, a routine (UpDateToolbars) is called which
checks various conditions and enables or disables buttons according to
those conditions.
This works perfectly in Word 97 and Word XP.
In Word 2003, after the call to UpDateToolbars all of the buttons
appear as if they were disabled (greyed out) except occasionally when
they all appear as if they were enabled.
The buttons are "repainted" correctly if the cursor is swept over
them.
Forcing a screen refresh at the end of the UpDateToolBars procedure
does not correct this.
Any suggestions gratefully received.
Geoff Edwards
Leeds, UK
e-mail: stopspambot@sixwillow.com
(replace the stopspambot bit with some
version of my name) Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62507
Problems with headers and footers - lengthy I'm sorry
Win 2K
Word 2K
Hi All
Thank you to anyone in advance who has the patience to read this. I have
tried everything and read tons in these groups to try and resolve the
problems, but I'm not sure there is a bullet proof way of doing what I need.
Here's the situation (I'll try to be brief but in fear that brief may not be
descriptive enough ....... here goes.... )
When a user presses Alt + S, an inputbox appears, the user is prompted for
the name of a witness, and the witness name is then inserted into the
document with a colon, two spaces and the word SWORN following their name.
Additionally, I bookmark the name for use in a table later on.
code snippet for Alt + S (NASTY but it works for now until I clean it up
hopefully with ranges)
**************************************************
Dim strSwornName As String
strSwornName = InputBox("Enter Name of individual being sworn")
'Inserts name of witness being sworn
With Selection
.TypeText Text:=StrConv(strSwornName, vbUpperCase) & ": " & "SWORN"
.ParagraphFormat.Space15
.EndKey unit:=wdLine
.HomeKey unit:=wdLine, Extend:=wdExtend
.Font.UnderLine = wdUnderlineSingle
.MoveLeft unit:=wdCharacter, Count:=1
.MoveRight unit:=wdWord, Count:=1
.MoveRight unit:=wdWord, Count:=1, Extend:=wdExtend
End With
strWitnessName = Left(strSwornName, 1) & ". "
strWitnessName = strWitnessName & Trim(Mid(strSwornName,
InStrRev(strSwornName, " ")))
'Marks Last Name as bookmark for header
strWitnessLastName = StrConv(Selection.Range, vbProperCase)
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, name:=strWitnessLastName
End With
'Marks Last Name as bookmark for table of contents
strFWitnessName = Mid(strSwornName, InStrRev(strSwornName, " ")) &
", " & Left(strSwornName, InStr(strSwornName, " "))
********************************************
When a user presses Alt +1 , I have the text "EXAMINATION IN CHIEF BY" + a
document property being placed at the current location in the document.
code snippet
********************************
With myRng
.Text = strChief & " "
.InsertAfter ActiveDocument.CustomDocumentProperties("PTitle") & _
ActiveDocument.CustomDocumentProperties("PLastName") & ":"
.Case = wdUpperCase
.Font.UnderLine = wdUnderlineSingle
End With
***************************************
In addition to typing the text, the current code takes the name of the last
bookmark it finds in the file (the name of a witness), moves to a specified
table( table 1), inserts the bookmarked text in the first blank row and
bookmarked text page number in a specific column which is determined by the
type of examination. (Alt + 2 enters the text "CROSS-EXAMINATION BY" ...
(thus specifying a different column). That part works just fine. (Not very
elegant, but here's the gist of it - there's more but I thought this would
be enough. This piece only takes care of the Examination in Chief)
************************************************
otable.Range.Rows(otable.Rows.Count).Range.Select
With Selection
.InsertRowsBelow 1
.Collapse (wdCollapseStart)
End With
myrow = Selection.Information(wdStartOfRangeRowNumber)
With Selection
.TypeText Text:=StrConv(Trim(strFWitnessName),
vbProperCase)
.MoveLeft unit:=wdWord, Count:=3, Extend:=wdExtend
.Font.UnderLine = wdUnderlineNone
.MoveRight unit:=wdCell
Selection.InsertCrossReference
ReferenceType:="Bookmark", ReferenceKind:= _
wdPageNumber, ReferenceItem:=strBN,
InsertAsHyperlink:=False, _
IncludePosition:=False
End With
*******************************************************
I also need the header on the page where EXAMINATION IN CHIEF or
CROSS-EXAMINATION BY appears to print in the header .. however in a
different format. If ALT + 1 is pressed and EXAMINATION IN CHIEF BY appears
in the body, then the header must read "FirstInitial LastName of Witness -
in Ch." minus the quotation marks. If ALT + 2 is pressed and
CROSS-EXAMINATION BY appears in the body, then the header must read
"FirstInitial LastName of Witness - Cr. Ex.".
I have created subroutines to assemble the names properly for insertion in
the header as they are actually coming from custom document properties not
formatted the way they need to appear in the header.
The difficulty I AM having is twofold:
Problem #1
The header on all pages from section 3 to the end of the document must
ALWAYS include at least the following:
1.
R. v Name of Defendant
in addition to what I have described above (the in-Ch. or cr-Ex).on the
third line
The number 1 is the page number and a period
The R. v Name of Defendant is a field in the header that looks like this:
{ DOCPROPERTY "Header1" \* MERGEFORMAT }
Problem #2
Although the text EXAMINATION IN CHIEF BY .... may appear on page 3, that
individual's testimony may well carry over several pages until he/she is
finally CROSS-EXAMINED. At the page where the text CROSS-EXAMINATION BY
appears, the header will once again change to reflect the fact that the
cross-examination has now begun on that page. The page number and R. v Name
of Defendant must remain in the header and if the examination in chief
appears on the same page, that text must also remain in the header. I will
then need "FirstInitial LastName of Witness - cr-Ex." to appear on a fourth
line in the header.
Once a new witness is sworn in, the process begins again. That is, the
EXAMINATION IN CHIEF will have to be re-set in the header until the witness
is cross-examined etc. etc.
The document will continue to proceed in the same manner as potentially
hundreds (although that's probably excessive) of witnesses could testify.
Thank you to anyone brave enough to have read all this and further, have any
suggestions or recommendations.
Please let me know if I can clarify anything or whether I could have somehow
posted this in an easier to read format.
Legal jargon mixed with vba???? .... am I NUTS?
Debra Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62504
Legacy Access2/VB4 app merge errors with Word 11
I have a network where all of the client machines were recently replaced and
are now running XP Pro SP2. Office 2003 is also on the new machines.
The legacy application was written in VB 4 and I have no source code
available. The Access version is 2.0. The application works as expected
and as it did before the upgrade with the exception of Microsoft Word
merging capabilities. The application creates a proper ".dat" merge
document but is unable to do the link. The .dat file contains a properly
generated header with the field names tab separated and the data from the
requested record (by entering the keycode value in a message box) tab
deliminted as well. The data is what it should contain.
The setup settings are properly directing the application to the correct
directory path and winword.exe file name. Word does not open and three
errors occur in succession according to the messages that appear:
In the title bar of the message box: "Merge Error (Word) #1056 and in the
center of the message box: "Not a valid filename."
Clicking on the OK command button brings up another error message box with
the title bar showing "31031 (0)" and the text in the message box being
"Invalid Source for link"
Clicking in the OK command button brings up another error message box with
the title bar showing "31004(0)" and the text in the message box being "No
object."
The document is a valid document and the path is correct. I have written a
workaround macro in VBA of Word to allow them, after responding OK to the
three messages in the legacy Access app, to press Alt-M in an open,
no-document Word application which presents them with the directory
containing the master merge document and containing the newly created data
source .dat file containing the header and record data as requested in the
legacy app. After selection of the requested file, I test the file name of
the .doc file and create a DataSourceFileName for .dat files over 8.3 and
then do the merge of the document to a new file with the .dat file created
and given as the source for the master document. This process proceedes
without a problem. I suspect that there may be some ODBC connectivity
problems between the legacy apps that don't know OLE and that are looking
for another type of data source other than ".dat" files. This was the old
way of providing a data source from which to merge via ODBC (to fake it out)
and the older DDE application connectivity.
I do not have the old app source code, the developer are not at all
interested in updating to anything later than Access 97 (believing that Bill
Gates is out to destroy them <bg>. Is there anything I can do, other than
writing a new application, to allow the users to merge with this old
application to Word v. 11? I have no problem accessing the tables via a
DSN-less SQLConnect() statement but the record comes through some 24 steps
in a "Logic" table in a different database than the actual data. I have
been doing database programming for 17 years but have little, brief
experience with Access but quite a bit with VBA, Visual FoxPro, SQL, and C.
It has been suggested that I write a dummy application in VB6 to impersonate
Word 6 and receive the file names passed and then use those and call Word 11
from this dummy app, passing the merge file and data source file names to
Word 11 on startup. I don't know how I'd go about "impersonating Word 6"
and create this "DDE sink" that's been suggested.
Any suggestions for any approach would be greatly appreciated? The
work-around is getting the users to the goal line but it's taking too many
downs to do make the
touchdown.
Justice Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62497
change
How do i change Word and Exel into my lanuage who is norwgian Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62496
Finding bad formatting
Dear people,
For some time now, I'm struggling to solve a VBA problem.
Some of you already gave some assistance, for which I'm great full.
I'm trying to find some bad formatting in a word document using VBA.
On all paragraphs are paragraph styles applied. On pieces of some
paragraphs, are Character styles applied. On other pieces of text, other
manual formatting is applied like "bold" or "Bold Italic".
I'm trying to detect the pieces of text that has no "character style"
applied and yet have other manual formatting is applied like "Bold Italic".
For example:
Some text is set to bold, this is wrong.
Other text has the character style "BOLD" applied, this is good.
I need to highlight all the bad formatting.
Can anyone please help me?
Thanks
JD Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62495
disable some shortcut key's
Hi
Does anyone know how to disable some shortcut key's like ...
CTRL + F3
CTRL + SHIFT + F3
CTRL + "2"
Thanx
JD Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62494
msmapi32.ocx vba vb problem
I made a mail application in word vba. It works fine but I didn't know that
someone installed vb 6 on my computer. Other people want to use the
application too and the activeX control: MSMAPI32.OCX is missing. Can I put
that ocx on a network drive. Those people dont have administrator rights and
can't install applications, only NAL-objects. A solution is making an exe
with the vb 6 wizard but to install that you must have rights to do that.
Does anyone know a solution. Put it in c:\windows\system32 or run a register
program in vbs code or something?
If I place the ocx on a drive on a user computer and click the microsoft
MAPI controls in the toolbox and choose the directory with the ocx it works
so it has not to bee registered or licensed, am I right??? CDO doens't work
it hits the firewall...
Thanks, Siebe Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62491
disable toolbar buttons
Hi everyone,
Does anyone know how to disable some toolbar buttons (so they apprear to be
gray) using vba ?
For example ..
the italic-, bold- and underline-buttons
the font-popup in the toolbaar...
Thanx
JD Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62486
Deleting a page forcibly
Hi,
I want to delete a particular *real page*.
Like many times if I copy data from let's say Web/ some software etc and
paste in to Word (I use word for Printing only !!!) then the last page would
be having no data (atleast it would be blank as far as am able to see) but
still even if am sitting on the period after the last letter in the Main
Story and if i keep pressing delete the Last page just wouldnt get deleted.
Why does this happen?
Is there a VBA solution to it (and yes, would be happy to know non-VBA
solution as well)
Thanks a lot,
Hari
India Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62475
Find string in table and move to next cell
Hello All
Windows 2K
Word 2K
I'm trying to locate a string (strFWitnessName) in a table in my document
and then move one cell to the right to enter a page number.
strFWitnessName could appear in 1 of three tables in the document ( but it
will never appear in all three)
I do not want to search the entire document as strFWitnessName will appear
throughout the document text as well.
I found the following code posted by Doug Robbins and tried testing it but
apparently I am just not familiar enough with vba to understand what it is
doing.
Dim i As Integer, j As Integer, myrange As Range
For j = 1 To ActiveDocument.Tables.Count
For i = 1 To ActiveDocument.Tables(j).Rows.Count
Set myrange = ActiveDocument.Tables(j).Cell(i, 1).Range
myrange.End = myrange.End - 1
If myrange.Text = strFWitnessName Then
ActiveDocument.Tables(j).Cell(i, 2).Range.Text = "pagenumber1"
ActiveDocument.Tables(j).Cell(i, 3).Range.Text = "pagenumber2"
End If
Next i
Next j
Any help would be greatly appreciated.
TIA
Debra Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62470
Special character not recognized
ActiveDocument.Bookmark("mybookmark").Range.InsertAfter "text"
where texts are texts that has special character created through
Insert>Symbol>ShortcutKey method.
How do I get around this problem? Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62469
AddressLayout
I was attempting to eliminate the United States of America for addresses
when I import an address from Outlook. Somehow in the process "United States
of America" got substituted for the zip code. No matter where I place the
{<PR_POSTAL_CODE>} in the address form, it comes out "United States of
America" I assume there is a table somewhere that sets forth those codes.
Any ideas.
Nick@nicksigur.com Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62467
automatically close a doc after user clicks on email send?
Hi All
I have a word form ready with the email header active in the document. When
I select Send on the email, the document remains open. I would like it
automatically close once the send button is hit. I found that the
ActiveWindow.EnvelopeVisible toggles the word email header.
I have got this far via the web but I really have no idea:
created a Class Module -clsobject:
Public WithEvents oApp As Word.Application
Private Sub oApp_DocumentChange()
' dunno what to put here
End Sub
created a module:
Dim oAppClass As New clsObject
Public Sub AutoExec()
Set oAppClass.oApp = Word.Application
If ActiveWindow.EnvelopeVisible = False Then
ActiveDocument.Close
End If
End Sub
Any ideas? Thanks in advance Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62456
SetFocus on a userform Does Not Work
I have a fairly simple userform with a frame and two
textboxes inside the frame. If a user makes an invalid
entry I want to display a message, clear the entry, and
set the focus back to the same field.
The mesgbox displays perfectly, and the entry is cleared
fine. However, the focus keeps going to the next textbox
in the frame. I am getting frustrated! I even tried
setting the focus back to the frame first, and then to the
field. I also tried using the Exit event with no success.
I am using the AfterUpdate event and the name of my
textbox is txtClientNumber. My code appears below.
Any ideas would be apprecaited. Thanks so much in advance.
Private Sub txtClientNumber_AfterUpdate()
Dim StrClientName As String
Dim rstClientName As ADODB.Recordset
Set rstClientName = New ADODB.Recordset
StrClientName = "SELECT client_name FROM hbm_client
WHERE client_code = '" & txtClientNumber.Value & "'"
rstClientName.Open StrClientName, Main.cnn
If rstClientName.EOF = True Then
MsgBox "That is an Invalid Client Number"
txtClientNumber.Value = Null
frmMain.fme1.SetFocus
txtClientNumber.SetFocus '***PROBLEM HERE
Else
rstClientName.MoveFirst
txtClientName.Value = rstClientName
("client_name").Value
End If
End Sub Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62453
Printing pictures in Word
if i insert a picture at say 12cm x 12 cm, word prints it at around 10.5cm x
10.5cm
It looks like the page is set up smaller than it should be, but its set up
for A4
Help please
Thanks in advance, Snaff Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62452
Can't add a reference to the specified file
Here's one for the Google archive, in case anyone else hits it.
On my development machine, I began getting an error when attempting to
set a reference within a Word VBA module to another Word template. The
error was:
Can't add a reference to the specified file
The template I was trying to set a reference to was one I have been
using for over a year without a problem. My machine gets pretty badly
beaten up while I'm coding and debugging, so no doubt I fried
something. Now here's the strange thing. The template to be referenced
was:
c:\My Programs\Foo\Foo.dot
The precise symptom: start word, hit Alt+F11, open a module, choose
Tools, References, navigate to and select the Foo template. PRANG!
Error.
Exit Word. Rename either the template *or* the folder *or* the folder's
parent, and everything works! E.g.:
c:\My Programs\Foo\FooA.dot -- no problem
c:\My Programs\FooZ\Foo.dot -- no problem
It was only when the template full path was
c:\My Programs\Foo\Foo.dot
that the error occurred. Very bizarre!
I reinstalled MS Office, cleaned the registry of all references to Foo,
but no joy.
It turned out that the problem was somewhere inside my XP profile. When
I logged in as another user, everything worked. I simply renamed my old
profile, then logged in as myself again. Presto! Problem solved. (I had
to harvest my favorites, Start menu, etc. from my old profile, but it
sure beat nuking and rebuilding the machine.
Hope this helps someone else. Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62448
How do I get data from MySQL ?
Is there a way to get data from a MySQL database? Then can I insert the data
into Word in some non-table format? I want to be able to place some data
within paragraphs of my document. Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62447
When sending a word document in an email i get an error "word can.
I'm trying to send a word document in an email when i get an error. The error
says "Word Cannot load the Email envelope". Why am I getting this error and
how do i fix it? Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62446
Calculating in VBA
This expression tells me which page I'm on:
Selection.Information(wdActiveEndPageNumber)
I want to do something if a page is odd or something different if it
is an even number.
Is there a way of doing this in VBA, please?
I was looking for something that would allow me to divide a page
number by 2. If the remainder was not zero then it must be an odd
number. That's my logic but I cannot work that in VBA.
Regards
Roderick O'Regan Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62442
Unable to insert word html file into a Word document
Hello,
I have a HTML document created by saving the document with Word using the
wdFormatHLMLFiltered. This works fine and I can see the document. However,
if I attempt to insert this HTML file into another word document I only see
the first line of the document. Is there some sort of restriction from
using wdFormatHTLFiltered and other word documents?
Thanks,
Jerry Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62441
What is wrong with this code?
Hello,
I´m trying to paste two cells (text) from Excel to Word. The code pasted
below does not completely do the trick - please could someone tell me what
is the problem, what must be added?
Problems:
1. If I leave out the ".Collapse wdCollapseEnd", the range A1:D1 gets
replaced by the range A2:A6. Then the range A2:A6 is formatted like I want
it to be (bold).
2. If I dont leave it out, the formatting is not correct, but both ranges
are being copied otherwise correctly. Then the range A2:A6 is not being
formatted at all, but copies the formatting from range A1:D1 (not bold).
Sub TW()
Dim AppWD As Word.Application
Dim DocWD As Word.Document
Dim RangeWD As Word.Range
Set AppWD = CreateObject("Word.Application.10")
AppWD.Visible = True
Set DocWD = AppWD.Documents.Add
With DocWD
Set RangeWD = .Range
Sheets("T").Select
Range("A1:D1").Select
Selection.Copy
With RangeWD
.Font.Name = "Arial"
.Font.Size = 12
.Font.Bold = False
.PasteAndFormat Type:=wdFormatPlainText
.Collapse wdCollapseEnd
Sheets("T").Select
Range("A2:A6").Select
Selection.Copy
With RangeWD
.Font.Name = "Arial"
.Font.Size = 12
.Font.Bold = True
.PasteAndFormat Type:=wdFormatPlainText
.Collapse wdCollapseEnd
End With
End With
End With
End Sub Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62439
Word Templates
Can word templates be lock down or controlled? What we are looking for is
locking down the template and let users change content of the templates.
Also, if the template changes, then what happens to the old content? Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62432
Automating mailmerge from VB ActiveX control.
Hi,
I'm having a problem executing a word mailmerge automated by an ActiveX
control embedded in an intranet web page.
I have an intranet application which allows users to upload word
mailmerge main documents, and then have other users of the intranet
execute mailmerges with data in our intranet database.
It all works a treat except when one of my users uploads a mailmerge
main document which has been created using an edited normal.dot. In
these cases word opens an Open Header Source dialog box. I can then
select any word document I like, and the mailmerge completes successfully.
It is the Open Header Source dialog which I want to prevent - as it will
certainly confuse some of my less savvy users.
If that same mailmerge main document is used on the machine that created
it, it works fine, without the extra dialog.
My code, for this part of the system, for what it's worth is:
'------------------------------------------------------------
Set objMSWordInstance = New Word.Application
' using the new word application ...
With objMSWordInstance
' make word visible
.Visible = True
' activate word applciation
.Activate
' create new instance of word document
Set objDummyDocument = objMSWordInstance.Documents.add()
' close the dummy document
objDummyDocument.Close (wdDoNotSaveChanges)
' create new instance of word document using the saved mailmerge
template
Set objSourceDocument = .Documents.Open(strMailmergeTemplateFilename)
' create new instance of Word mailmerge object
Set objMailMerge = objSourceDocument.MailMerge
' using the new mailmerge object ...
With objMailMerge
.OpenHeaderSource strHeaderRecordFilename, wdOpenFormatText,
False, True
' use the temporary file we've just created as the word
mailmerge data source
.OpenDataSource strFieldValuesTempFilename, wdOpenFormatText,
False, True
' set the last record property of the data source
' (this means that the blank record we stuck on the end
' of the data records will not be displayed)
.DataSource.LastRecord = intTotalRealRecords + 1
' execute the mailmerge!
.Execute (True)
End With
' dereference mail merge object
Set objMailMerge = Nothing
' close the original source document (discarding changes)
objSourceDocument.Close (wdDoNotSaveChanges)
' dereference word document object
Set objSourceDocument = Nothing
End With
' ---------------------------------------------------------
Debugging has told me that it is the .OpenHeaderSource command which is
causing the dialog to open.
In the above code the strHeaderRecordFilename variable is the path &
filename of a text document which holds the merge field names. The data
records are held in a text file for which the strFieldValuesTempFilename
variable holds the path & filename.
Does anyone have any suggestions?
Matt Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62430
Syntax Blues - A repost
Hi,
I messed up in explaining my requirement in my previous post ("text
replacing based on a true condition") in
the --microsoft.public.word.vba.beginners -- hence rewording the same here.
(am not conversant with word other than manual formatting and using it as a
Scratch application. I work primarily with Excel)
a) Whats' the syntax for programmatically knowing the actual page number of
a document. Like if the cursor is in page 65 , I should be able to get the
value 65.
I tried the following
Msgbox activedocument.selection.pagenumber
but getting a Run-time error "438" - object doesnt support this property or
method.
b) Whats the syntax for programmatically looping through each sheet in the
document. Like I can write the following
For I = 1 to NoOfPagesInTheDocument
But, how would I find the value of NoOfPagesInTheDocument.
Basically I want the value for total no of pages in that document. This
value also gets displayed in the Word taskbar/information area in the
bottom. Like where it says 45/750, which means am at the 45th page and 750
is the NoOfPagesInTheDocument.
c) Whats the syntax for restricting the Search/Find/replace Feature to a
particular page only. Like , if am in a For Loop as described in b) and if I
want to restrict my find/replace only to the present page, then how do I do
it?
Please guide me.
Thanks a lot,
Hari
India Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62423
Cut and paste to new document
Hi,
I have code that actually find the 1st 'S' of the document where it will
cut and paste to new document. Can i coded in vb that it will find the next
'S' and vut and paste instead.
With Selection.Find
.Execute FindText:="<[FS]????????>", MatchWildcards:=True,
MatchWholeWord:=True, Wrap:=wdFindContinue, Forward:=True
'MsgBox "!"
'Invoke the SaveAs box
With Dialogs(wdDialogFileSaveAs)
.Name = Trim$(Selection.Text)
.Show
End With
End With
regards,
ben Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62422
Another tagging question
The complexity of this task got my attention. Let me explain as best I can:
Problem / Input:
1. djskljfdslkfjdsf
2.. sadaskdsa
3.. dsadsadsa
1.. fsdfdsf
2.. dfdsfds
3.. dfdsfds
4.. djasda
Desired Output:
<LISTGROUP>
<LISTITEM>
<NUMBER>1.</NUMBER> <TEXT>djskljfdslkfjdsf</TEXT>
</LISTITEM>
<LISTITEM>
<NUMBER>2.</NUMBER> <TEXT>sadaskdsa</TEXT>
</LISTITEM>
<LISTITEM>
<NUMBER>3.</NUMBER> <TEXT>dsadsadsa</TEXT>
<LISTITEM>
<NUMBER>a.</NUMBER> <TEXT>fsdfdsf</TEXT>
</LISTITEM>
<LISTITEM>
<NUMBER>b.</NUMBER> <TEXT>dfdsfds</TEXT>
</LISTITEM>
<LISTITEM>
<NUMBER>c.</NUMBER> <TEXT>dfdsfds</TEXT>
</LISTITEM>
</LISTITEM>
<LISTITEM>
<NUMBER>4.</NUMBER> <TEXT>djasda</TEXT>
</LISTITEM>
</LISTGROUP>
Notice how each individual item is encapsulated in a <LISTITEM> tag and how
one level (3a, 3b, 3c) are encapsulated under 3's LISTITEM tag. Well, this
is hard to explain but I hope you can see the logic.
Now, there could be upto 4 such levels (i.e) 3.a may have a 3.a.i which may
further have a 3.a.i.A and so on. The taggings need to be done
appropriately. Also, the numbers may either be typed or could be part of the
automatic bullet lists that Word has. Also, if manual spaces are used
instead of bullet lists, they are usually of the right number. I mean,
1. dasdas
a. dssffsd
b. sadajkjs
c. dfskjs
is also possible (spaces usually have a + or - 2 error rate)
Questions:
1) Any idea on how I should go about doing this in the most error-free
fashion? We get many documents to process and the most error-free method is
desirable.
Before I begin coding this, I thought I would see if any one had any special
tips I should take into consideration.
Thank you for your time/ response.
Vince Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62421
Save doc as Webpage but cannot view in browser at the same time
I am writing the following code, it will popup a save as dialog, when I got the path and name info, i run ActiveDocument.SaveAs to save doc as webpage. After that, I tried to call ActiveDocument.FollowHyperlink to open that webpage, however, nothing happen.
But then, i tried to call ActiveDocument.FollowHyperlink to open a file which is saved before, it works fine.
I feel strange that if i just saved the file, i can't immediately call ActiveDocument.FollowHyperlink to view the page. Anyone can help?
Dim Path, Name, fullPath As String
With Dialogs(wdDialogFileSaveAs)
If .Display Then
Path = WordBasic.FileNameInfo(.Name, 5)
Name = WordBasic.FileNameInfo(.Name, 4)
fullPath = Path & Name & ".html"
ActiveDocument.SaveAs FileName:=fullPath , FileFormat:=wdFormatHTML, _
LockComments:=False, Password:="", AddToRecentFiles:=False, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
ActiveDocument.FollowHyperlink fullPath
End If
End With
--
Message posted via http://www.officekb.com Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62420
protected form
In a protected form, can users insert a picture into a form field? Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62419
One issue about the GetCommandBars
Hello,
I am writing a program based on COM&Office word.
The codes are:
.......
_Application m_app;
COleException e;
m_app.CreateDispatch("Word.Application.8", &e);
....
Now, I want to get the CommandBars. So, I do like this:
........
LPDISPATCH lpdisp_comBar = m_app.GetCommandBars();
........
My question is:
How to get the object of 'CommandBars' from the 'lpdisp_comBar'?
I don't know WHICH CLASS represent the object 'CommandBars'.
If somebody know how to do it, please tell me.
Thanks a lot.
--
Message posted via http://www.officekb.com Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62418
Creating Template with drop-down boxes
I need to create a Template in Word for multiple users. It needs to have
drop-down boxes with fill-in choices to select from a list. I know Word can
do this, but I don't know to begin. I don't understand the instructions given
because they include locating an already-created Template with drop-down
boxes and I can't find one.
HELP!! Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62416
how to select range of text to delete?
Given a document with the following text:
The quick brown fox jumped high.
There is a cat over the lazy dog.
The quick brown fox jumped.
There is a bird over the lazy dog.
How can I write a macro to delete the text between â??jumpedâ?? and â??overâ?? so
the document ends up like:
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The following macro finds the end of â??jumpedâ??:
Sub FindFoxyJump()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "jumped"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub
Specifically how can one begin a selection from that location, and extend it
to the beginning of â??overâ??? While it is simple to select text by moving the
cursor with
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
There seems to be no such Extend:=wdExtend argument for
Selection.Find.Execute.
Please help. I am really stuck.
--
Regards,
-Ron Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62401
Replacing (removing) numbers from beginning of line (Word 2000/Windows)
Hello All,
I'm slowly but surely gaining an education into at least the basics of
writing macros. I've got something that is pretty close to what I want,
but not quite there.
I've got a bunch of documents that have step numbers manually entered.
These steps should always be in one of four styles. So I put together a
macro that looks at the style and then searches for wildcard text that
should related to the step numbers and the following tab, and replaces
them with nothing.
It mostly worked, but would occasionally delete some other text that I
didn't want to delete in some of the lines.
Now I know the step numbers are always the first thing on a line, so I
added a paragraph mark to my wildcard text string. I figured that would
ensure it would only look for the numbers that follow a return.
However, when I added the paragraph mark to the .Text and
.ReplacementText entries, my macro gets stuck in a loop between "Do
While . . ." and "Loop". Entries.
Am I going about this the wrong way, or am I just making an ignorant
mistake?
Any help will be greatly appreciated!
Dan
---
Sub MacroName()
Dim FindStyle As Variant, k As Integer
FindStyle = Array("Para 1.1", "Para 1.1.1", "Para 1.1.1.1", "Para
1.1.1.1.1")
On Error Resume Next
For k = 0 To 3
With ActiveDocument.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^p[1-9].*[1-9]^t"
.Replacement.Text = "^p"
.Format = True
.MatchWildcards = True
.Style = FindStyle(k)
Do While .Execute(Replace:=wdReplaceAll)
Loop
End With
Next
End Sub Tag: Can MS word accept an input provided at the begning of the docume. Tag: 62396
Can MS word accept an input provided at the begning of the document at
diffrent places where same filed name is provided with out prompting