Autonew macro doesn't fire on new document
I have a quite annoying problem with the autonew macro. I am using Word
2003.
In a template, i made the autonew macro, i tested it, and it does exactly
what it is supposed to do, as long as i am working directly in the .dot
file.
When i doubleclick the .dot file Word opens with a new document filled with
everything from the template, even the macro, but it's not firing up, and
when i go to Extra --> Macro --> Macro's... it is not showing the macro
anymore. If i then open Visual basic, all the code is there. Then if i add a
bit of extra code (another sub that just puts up a MsgBox with some crap)
suddenly all the macro's are usable again.
This kinda nullifies the use of the autonew macro as i still have to
manually add code and start it up. Does anyone have any clue why my macro
code is copied to the new document, but is not available for use until i
edit the code?
Regards,
M. Vlaardingerbroek Tag: add 28 days from present date Tag: 89053
Auto macros
I am trying to do Auto Macros in a different template than the
normal.dot. I create a module called AutoClose or AutoExec or AutoNew
and within those modules I have a sub Main(). None of these macros will
run unless I place them in the normal.dot. I can't have them in the
normal.dot as I cannot replace the clients normal.dot. I created a
different add in called adn.dot and place them in there as a module but
it won't run unless I move them back to normal.dot. Any suggestions? Tag: add 28 days from present date Tag: 89044
Error handling in VBA code
Hi,
I've developed the following function to test if some style does exist in a
document:
Function xstyle(aStyle As String) As Boolean
Dim sty As style
On Error GoTo notexist
Set sty = ActiveDocument.Styles(aStyle)
Set sty = Nothing
xstyle = True
Exit Function
notexist:
xstyle = False
End Function
For some time this has worked, but now when the style does not exist the
statement "Set sty = ActiveDocument.Styles(aStyle)" generates an error "the
asked member of the collection does not exist" and stops execution in stead
of jumping to the label Notexist:.
What can be at hand? Why the error handling doesn't work?
Thanks for suggestions
Henk Tag: add 28 days from present date Tag: 89041
put wordcount for each page on page header automatically
hello everyone
I write news scripts in MS Word and I need my wordcount of every page
somewhere, preferrably on teh header.
Is there a way I could achieve this.
If the info could be updated everytime I save would be great.
Hope some one could help.
thanx
ahmed Tag: add 28 days from present date Tag: 89039
Advice on how to access and update Word .docs located on a central web server
Hey Folks,
I've been handed a potential design and I have no experience with such a
scenario:
We are looking at putting Word .docs on a central web server. Barring
security and / or other limitations, how
would one access Word documents to retrieve and insert material? I am
particularly interested in solutions that would be platform-transparent
(e.g. the web server might be a UNIX server where Microsoft solutions are
not available)?
I'm mainly looking for a good starting point utilizing VBA to access and
update these .docs programmatically.
Thanks & Regards,
TC Tag: add 28 days from present date Tag: 89037
Word 2003 cannot open Word 2000 Document
I have word documents created using Word 2000 SP3 which works fine on all
office 2000 PC.s but i am having a problem opening the document on office
2003. the following error appears:
Word experienced an error while trying to open this file
* The file may be corrupt try File/Open and Repair option
*check the file permissions of the documents or drive
*make sure there is sufficient free memory and disk space
*open the fiel with the text recovery converter
I have copied the file to memory stick and onto my desktop and there are no
permissions set.
There is over 120mb free memory so this should not be the problem.
We do not use Norton Antivirus, instead CA Antivirus. To test on different
environments I have removed the antivirus and firewalls from two pcs running
Word 2000 and Word 2003 and still get the same results as listed above.
MSFT Knowledgebase is worthless for this issue.
PLEASE CAN SOMEONE HELP!!!!! Tag: add 28 days from present date Tag: 89035
Auto fill and macros in a protected form
I have read through all similar postings, but none quite fit.
I'm trying to set up an order form with a "bill-to" and "ship-to" that may
or may not be the same. I have a few questions:
1) How do I use a check box labeled "Same" and have all the bill-to fields
(name, address, city, state, etc) auto fill in the ship-to fields. Sometimes
the bill-to and ship-to are not the same so I need to be able to track both
sets of data.
2) How do I track all data (whether the fields are changed or not)? Does the
solution to question 1 "overwrite" the fields if the data is the same?
3) I have set up my own macro, but in order for the form to work, it need to
be protected, and then if the form is protected, my macro errors, telling me
to unprotect the document. How do I get that to function properly?
Thanks in advance Tag: add 28 days from present date Tag: 89027
Auto Split/Save document into multiple documents - Is this possibl
E.g. 100 page document that I want to save into 10 separate files of 10 pages
each. File 1 - pages 1 thru 10, File 2 - pages 11 thru 20, etc. Is there an
easy way to do this kind of thing? Any help would be appreciated greatly Tag: add 28 days from present date Tag: 89023
Hyerlink Modification help needed
Hello
I have a several hundres pages with content in the following format:
<text as hyperlink><1 empty space><any text any size>
I want to have it converted to somehting like the following:
<Text from oringal hyperlink astext>
<hyperlink as URL from original hyperlink>
<any text any size>
Can someone please help on this?
Thanks for any feedback,
Frank Tag: add 28 days from present date Tag: 89016
Attn. Doug Robbins--Conditional Header/Footer
I hope this message reaches Doug Robbins, Word MVP, but any help from anyone
else is welcome.
Some time ago I queried this NG about conditional headers/footers and the
need to have Word display "For Official Use Only" in the footer when there
was for official use only material (marked as (FOUO)) in the text.
The following is what Doug Robbins wrote, but I'm having difficulties with
this. When I follow these directions, the field in the footer simply displays
"STYLEREF". Also, when I have the AutoCorrect option enabled and type
(FOUO)--(which automatically converts the style of the target paragraph to
"Official")--Word inserts a line break, which I am hoping to eliminate.
Here is what Doug wrote and if you can answer the questions above, I'd be
grateful, REALLY grateful!
---Create a new character style. I called the one I used "Official". Now
type (FOUO) and select it and apply that style to it. Then with that
selected, from the Tools menu, select Autocorrect options and on the
AutoCorrect tab you should see (FOUO) in the "With::" section of the "Replace
as you type area". Click with the mouse on the "Formatted text" radio button
and in the "Replace:" section type fouo then click on add. Now in your
document, whenever you type fouo and press the space bar, it will be replaced
the (FOUO) formatted with the "Official" style. Now, in the footer, insert
the following field construction--{ IF {STYLEREF Official } = "(FOUO)" "FOR
OFFICIAL USE ONLY" "" }
Now on any page on which you do not want the "FOR OFFICIAL USE ONLY" to
appear, just select something and apply the Official style to it.
Hope this helps--- Tag: add 28 days from present date Tag: 89015
Rename Option Button
I'm trying to create a form that makes a user select a sepcific item and fill
in the details. eg the button would be Detail and the text field would
contain 1/S201.
or Spec Section: 099900 or Sheet: A405. Right now all I get is the "O" radio
button with Option Button 1 right after it then the text Detail and then the
text box.
--
M_Roberts
Research causes cancer in rats. Tag: add 28 days from present date Tag: 89014
Search & Delete Notes Pages
I posted this as a vague question some time back, and was asked for
more detail... so, I'll try and clarify:
I write training documentation, and in this documentation we
occasionally insert an 'instructor notes page'... which is basically a
page (always even-numbered) containing notes for the teacher regarding
the content on the next page. A document may have any number of these
notes pages, and we currently are using an autotext entry to insert the
page based on a heading style that breaks the page (so, no formal
page-break is used when inserting). However, this approach could be
changed.
After creating a document with n numbers of notes pages, I need to be
able to run a script or macro to programmatically loop through and
delete all of these notes pages. One of my co-workers recommended
attaching a bookmark to the notes page autotext, and then creating code
to loop through and delete the bookmarks (we don't use bookmarks
currently), resulting in a notes page free document. However, I found
out that I'd need a new bookmark name for each notes page I insert!
This becomes a problem for deletion because, even if I manually
bookmark every notes page, I don't have any code/script/macro that
would delete ALL sections defined by bookmarks within a document.
If there was a way to just say, "Delete all sections that are
bookmarked within this document." we may have a solution. Otherwise,
let's not think about bookmarks. Is there a way I could use
find/replace on the style used for the heading text on the notes page?
Or, perhaps use a specific font for notes and find/delete that font
style? Or could I somehow customize the page/section breaks for notes
pages? The possibilities are wide-open.
I look forward to your feedback, and feel free to ask questions if
anything needs clarification. Tag: add 28 days from present date Tag: 89007
Password protect all sections in a document
I've had a macro to password protect documents for a while and it works
fine - except for one issue I just found. When the macro is run on a
document that was once protected for certain sections, only those
sections are protected. The only way I can protect all the sections is
to manually protect the form and individually check all of the sections
in the options. My current code is as follows:
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Password:="mypassword", NoReset:=False,
Type:=wdAllowOnlyFormFields
End If
So I was playing around to see how a macro would record if I did only
want to protect certain sections. By doing so, I noticed it has a new
line for each section. So if a document had 5 sections, and I wanted
to ensure all of the sections were protected, I would need the
following code:
On Error Resume Next
ActiveDocument.Sections(1).ProtectedForForms = True
ActiveDocument.Sections(2).ProtectedForForms = True
ActiveDocument.Sections(3).ProtectedForForms = True
ActiveDocument.Sections(4).ProtectedForForms = True
ActiveDocument.Sections(5).ProtectedForForms = True
ActiveDocument.Protect Password:="mypassword", NoReset:=False,
Type:=wdAllowOnlyFormFields
The "On Error Resume Next" command, btw, is needed to make sure I don't
get an error if the document has less than 5 sections.
I've done plenty of searching, but I can't find any code that is
simpler. I wanted to do something like
ActiveDocument.AllSections.ProtectedForForms = True
or
ActiveDocument.Sections(1 - 5).ProtectedForForms = True
but nothing seems to work. Is there a simpler way to write this macro?
Thanks in advance,
- Mike Tag: add 28 days from present date Tag: 89006
multiple copies in different printer trays
I need help........ I have a word template and want to print 3 copies,
where the first copy goes to tray 1 and the remaining copies to tray 2
of a printer. Can someone help me. Tag: add 28 days from present date Tag: 88997
Searching for and Replacing Multiple items in a macro
Hi:
There is a financial messaging service known as SWIFT. SWIFT does not allow
the usage of certain characters in its messages. I am attempting to create
some code that will strip a Word document of the invalid characters â?? and
preferably replace the invalid character with a highlighted space so the user
can easily identify what the document will look like without the invalid
characters. The following code successfully removes the â??*â?? character from my
document. I would like to modify the code so that it will search for a list
of other characters such as &, $, %, #, etc. and remove them from the
document as well. Ideally, I would like the space where the character was
removed to be highlighted so the user can see where the character was
removed. (I am fine replacing the character with the â??spaceâ?? character.) Is
there a way to search for and replace multiple characters without having to
repeat the code multiple times? I havenâ??t done a lot of programming in Word â??
but have a basic understanding of VBA in an Access environment. Any help
would be greatly appreciated.
Thanks,
Dave
(The following code was created using the macro recorder in Word.)
Sub RemoveInvalidISO15022characters()
' Removes Invalid ISO15022 characters from document
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "*"
.Replacement.Text = ""
.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: add 28 days from present date Tag: 88996
FileSearch
I wrote several macros in Word 95 and 97 which were searching for files with
specific words in the file text, but I cannot convert them into Word 2003 or
write new macro in Word 2003 of this type. I cannot insert words for search
into the "text or property" property in the FileSearch object:
With Application.FileSearch
.NewSearch
.FileType = msoFileTypeOfficeFiles
.Text Or Property = ???
.LookIn = Directory
.Execute
In a way to search for files which contains several keywords. For instance,
I have to find all files in a directory which contains words "bread",
"butter" and "pepper".
In the early versions of Word Basic it was enough to insert "&" between the
search words, but I do not understand how to make it in Word 2003.
I tryed to record macro from screen, but Word 2003 display empty window
after recording such macro. I cannot use earlier version of Word, because
they cannot open .htm files without frequent crashes.
I make my life money with searching files in Word, and I am currently in
the dead end. I am not a programmer, but live forced me to do the simple
things with macro.
Please, if somebody has an idea, help me.
Petr Dombrovski, Graz Tag: add 28 days from present date Tag: 88992
VBA Write to file error
I am working on a template for monthly reports; the top part of the
form is a table full of the usual parameters (Project Number, Leader,
Sponsor, Month, Hours Worked, etc). Management wants to be able to
grab all the values and dump the data into an Excel file.
My approach was to create bookmarks throughout the table. Say for
instance I had two cells. First one is Project Leader, and the next
one is Terry Detrie. I'd set bookmark for the first cell, then tab
over to the next and grab the selected text. I'd cycle through all
the bookmarks this way, save the text to an array, and then write the
array to a text file. This text file could then be read by Excel
(also via macro). If anyone thinks my approach is useful, I will post
the code.
Is there a more direct way to transfer data from Word to Excel?
If 'yes', which is easier, running the code from Excel (opening and
reading Word document) or from Word (opening and writing Excel
spreadsheet)?
Terry Tag: add 28 days from present date Tag: 88987
Auto fill-in multiple documents
I don't get paid enough for this...
I know how to create a user form.
And I know how to use the ActiveDocument properties to automatically take
data from the user form and put it into a document in form fields.
What my boss wants now, is for that to work with MULTIPLE documents.
I.E. a new employee comes in to our company and filles out a user form
(document) asking basic info like name, social, phone numbers, address, etc.
and when they are done:
Word opens up employee profile.doc and fills in all the data in the form
fields in there, then opens up the W--4 form and fills in all the data in
the form fields in there, and opens up the I-9 form and fills in all the data
in the form fields there...
I guess my question is: how do I get VB to OPEN a document and propagate
that data into the fields in it? Tag: add 28 days from present date Tag: 88979
Adding complex cross-reference
I tried searching for a solution to this, but I haven't been able to
hit the magic string of key words that might hit on a solution. I have
a table that lists the subsection number, the heading text, and the
page number for each subsection. Right now I'm doing it manually by
putting the cursor in the first cell, inserting a cross reference to a
paragraph number, tabbing to the next cell, inserting a cross reference
to paragraph text, and tabbing to the next cell, then inserting a cross
reference to a page. I turned on macro record and generated these two
blind alleys:
Sub Paragraph_CF()
'
' Paragraph_CF Macro
' Macro recorded 8/2/2006 by whitlev
'
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdNumberRelativeContext, ReferenceItem:="1", _
InsertAsHyperlink:=True, IncludePosition:=False,
SeparateNumbers:=False, _
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdContentText, ReferenceItem:="1",
InsertAsHyperlink:=True _
, IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdPageNumber, ReferenceItem:="1",
InsertAsHyperlink:=True, _
IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdNumberRelativeContext, ReferenceItem:="2", _
InsertAsHyperlink:=True, IncludePosition:=False,
SeparateNumbers:=False, _
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdContentText, ReferenceItem:="2",
InsertAsHyperlink:=True _
, IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdPageNumber, ReferenceItem:="2",
InsertAsHyperlink:=True, _
IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdNumberRelativeContext, ReferenceItem:="2", _
InsertAsHyperlink:=True, IncludePosition:=False,
SeparateNumbers:=False, _
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdContentText, ReferenceItem:="3",
InsertAsHyperlink:=True _
, IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdPageNumber, ReferenceItem:="3",
InsertAsHyperlink:=True, _
IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdNumberRelativeContext, ReferenceItem:="1", _
InsertAsHyperlink:=True, IncludePosition:=False,
SeparateNumbers:=False, _
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdContentText, ReferenceItem:="1",
InsertAsHyperlink:=True _
, IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdPageNumber, ReferenceItem:="1",
InsertAsHyperlink:=True, _
IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
End Sub
And then I tried this:
Sub CF()
'
' CF Macro
' Macro recorded 8/2/2006 by whitlev
'
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdNumberRelativeContext, ReferenceItem:="72", _
InsertAsHyperlink:=True, IncludePosition:=False,
SeparateNumbers:=False, _
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdContentText, ReferenceItem:="72",
InsertAsHyperlink:= _
True, IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:= _
" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdPageNumber, ReferenceItem:="72",
InsertAsHyperlink:=True _
, IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:=" "
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdNumberRelativeContext, ReferenceItem:="73", _
InsertAsHyperlink:=True, IncludePosition:=False,
SeparateNumbers:=False, _
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdNumberRelativeContext, ReferenceItem:="73", _
InsertAsHyperlink:=True, IncludePosition:=False,
SeparateNumbers:=False, _
SeparatorString:=" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdContentText, ReferenceItem:="73",
InsertAsHyperlink:= _
True, IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:= _
" "
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdPageNumber, ReferenceItem:="72",
InsertAsHyperlink:=True _
, IncludePosition:=False, SeparateNumbers:=False,
SeparatorString:=" "
End Sub
But editing them to update from, say, "72" to "73" seems like it would
take longer than doing it manually. Surely someone else has had this
need before I did. Dare I hope there's a macro out there for this?
TIA--Eva Whitley Tag: add 28 days from present date Tag: 88978
How do I parse a document?
Hi,
I've got a 1500+ lines MS-Word 2003 document that contains plenty of short
articles. Each article begins with a bulleted, bold-type title, styled with
the 7th bullet from Word's bullet gallery found at "Format | Bullets and
Numbering".
I want a macro that does the following:
- parse the whole document and extract all bulleted lines styled with the
7th bullet.
- populate a listbox with the titles (extracted above) so that I can choose
a topic and jump to the corresponding article.
I'm new to VBA programming and don't know how to tackle the problem.
I barely was able to get the line count with a piece of code I copied and
pasted from somewhere like so:
Dim NumLines As Long
With ActiveDocument.Range.Find
.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
End With
NumLines = ActiveDocument.ComputeStatistics(wdStatisticLines)
MsgBox ("The document contains " & NumLines & " Lines")
End Sub
So, NumLines holds the document's line count. Now, how do I continue from
here to get the rest done? (Word's object model is huge and I'm stuck).
Guidelines and pointers appreciated.
Thank you.
Fernando Ronci
E-mail: fernandoronci@hotmail.com Tag: add 28 days from present date Tag: 88977
Foolproof way to add toolbar button for .dot file
Is there a foolproof way to make a global template file, a .dot file, add a
button to the standard Word toolbar, the one with File, Edit etc.
I have seen and tried many suggestions, such as putting the code that adds
the button in:
- an AutoOpen Sub
- an AutoExec Sub
- the Document_Open event
- Just adding the button manually and saving the .dot file
with the added button.
The last one was the only one that seemed to work, but when I altered the
location of the .dot file from the
Startup folder in C:\Program Files\ etc. to the one under Documents and
Settings it didn't work anymore.
Surely, there must be same place to put the code so it will run when the
.dot file opens/loads.
RBS Tag: add 28 days from present date Tag: 88976
OLB enum values
I am creating a class to connect to Microsoft Word using VC++ 6.0 ClassWizard
and the object library MSWORD.OLB.
Most of the function calls in this class use the Varient type to pass
parameters, but I cannot find the actual values for the enumeration types so
I can pass in that value. Does anyone know how or where these enumeration
types are defined.
For example, WdUnits is composed of wdCharacter, wdWord, wnSentence, etc.
Thanks for your help.
Phil Tag: add 28 days from present date Tag: 88965
Print sample of all fonts
I am looking for the VBA code to print a sample of all the fonts in Word. I
am using Word 2003.
Thanks. Tag: add 28 days from present date Tag: 88964
Merging 2 list documents.
I have 2 notepad documents consisting of 16 character lines. One is
380,000 lines, the other is 20,000 lines. Is there a way to merge the
two so that the 1st line of the smaller ends up as the 20th line of the
larger, second line of the smaller ends up as the 40th line of the
larger and so on untill all 20,000 lines are evenly distributed within
the larger giving me a final document of 400,000 lines consisting of
the lines of both original documents and an even distribution of the
20,000 lines within the 380,000. I couldn't use Excel because the
characters are digits and Excel truncates the last digit to a zero. I
have opened both within MS Word but couldn't find a setting for doing
this. Anyones help is greatfully appreciated. Tag: add 28 days from present date Tag: 88962
Spell Check Macro in Forms
I created a form with form fields a few months ago and it is protected. I
got a call from a uset stating they could not spell check the info they
typed. I did some research and found a Spell Check code and I pasted it into
the code for Visual Basic, but I could nver get the Macro to work. I then
decided to just record a basic macro of spell check. I inserted it on my
toolbar and change it from text to a button. I typed on the form and clicked
the button to test it, but it took me to Visual Basic instead of checking the
document. Help! How can I get this to work - I have never used Visual Basic
before, so I'm a bit lost. Tag: add 28 days from present date Tag: 88961
How to merge two raw rtf documents?
Hello All,
We need to merge two rtf documents automatically without the user seeing.
The combined product of this merge is then shown to the user.
Currently we :
open the docs using notepad,
remove the last outer brace from the first doc
and the first outer brace from the second.
We then save them to a new rtf text document and then open this in word.
However this is causing problems with font tables and other items in the
headers of the rtf.
We have tested using Word automation but want to know if there is any other
way or a recommended way of doing this?
We currently do the merging of the rtf on the server side. Moving to using
Word Automation will mean we need to rely on the COM component server side
which as the following link shows is not a good idea:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2
We are considering moving the merging client side and therefore we can use
Word automation but this does add extra time to the client viewing the
document.
I presume that the method of merging the rtf by removing the braces is a
complete no no? Has anyone ever tried doing it this way? If we can
categorically rule this out we can push forward with the Word Automation.
Thanks for your help Tag: add 28 days from present date Tag: 88959
Automation Error using Web Browser Control to Display Word Document
I am writing an addin for Microsoft Word, and I have a requirement to
show a (different( word document in a Web Browser Control on the form.
The code is:
WebBrowser1.Navigate ("c:\test\test.doc")
When I run this I get the error:
Run-time error '-2147417848 (80010108)':
Automation error
The object invoked has disconnected from its clients
I thought it was my pc so I rebuilt it, and same problem, it works fine
from excel though... any ideas? Tag: add 28 days from present date Tag: 88955
Extract doc into text with 75 char line length
Does anhyone know of a VBA command that will take a Word doc paragraph and
convert it to (approx) 80n chars in width, while splitting the line at the
end of a word (ie, not to split at exactly 80 chars, but to split at the
last full word before the 80 chars is reached).
My problem is that we export the Word doc text into a database by extracting
the textual content (as ascii text) and the database app cannot present the
wider lines betyond 80 chars. I need to split the lines at the 80 (or less)
char mark and insert a CRLF so the db app can handle it for display.
Much appreciated.
Terry Tag: add 28 days from present date Tag: 88947
Automatically insert date when user selects from a form drop-down
I am using Word 2003 and have created a form for users to complete. I would
like to have a field that automatically inserts today's date when a user
changes their selection in a drop-down field.
For example, if a user selects a particular status from the status
drop-down, the corresponding status date field is automatically updated to
today's date.
A user may not necessarily select a new status each time they open the
document, so it has to be specific to the corresponding drop-down.
Thanks! Tag: add 28 days from present date Tag: 88946
Deleting objects on page
If a document has a number of pages and one of those pages has a
number of objects (in this case text boxes) how can I select these and
then delete them, please?
There is an "Ah, yes but..." factor here: these pages have a very deep
top margin of about 9 cm. The objects are located in that space
between the top margin and the top edge of the paper.
My code of:
Activedocument.bookmarks("\page").Range.Select
Selection.Delete
...removes everything within the boundaries of the page's margins but
nothing outside of these.
Is there a way of selecting these extra-marginal objects, please?
Regards
Roderick Tag: add 28 days from present date Tag: 88944
Smart Tag/XML to create doc that compiles sections from multiple d
I have several reports that are arranged into four sections, (s1, s2, s3,
s4). I am looking for a way to be able to create a document that pulls the
text/charts from each section on each report. I was thinking that XML smart
tagging would be what I would need to do, but I don't know how to create an
application or a "transform" that would pull the data. Ideally, I would want
to be able to create an ad hoc document that would pull and arrange all the
s1 sections from each report, and arrange them into one fluid report; or be
able to pull data from s1 and s3 and do the same thing. Any ideas?
Thanks,
Scott Tag: add 28 days from present date Tag: 88932
Reliable Character counts without opening word
I need to get reliable character counts from documents submitted in word
format.
*Reading them from structured storage isn't reliable, as by default fast
saves are enabled and the count isn't up to date as far as I can tell.
*Word on Macs doesn't save using structured storage.
Opening word is to expensive to do to get counts with doc.Characters.Count()
5000 openings of word crushed the system last year, and noone wants to by 10
more servers just to open word. I have thougth of keeping word running and
opening/closing documetns as necessary, but that is still a lot of Processor
time. Aside from that Characters.Count counts Paragragh symbols and other
things that aren't Charaters to the final print layout.
Is there a standard way to get Char counts from word documents composed on
different platforms without opening word everytime? ANd if I have to buy 10
copies of word and 10 servers to get character counts is there a way to get
them reliably without counting markup characters as characters?
TIA for any advice or direction.
~reed Tag: add 28 days from present date Tag: 88930
Use "Read Only" Parameter in FileOpen DDE Function with Office 200
Could anyone provide information please how to use the "Read Only" Parameter
with the FileOpen DDE Function?
Articles on the internet (e.g.
http://word.mvps.org/FAQs/AppErrors/ReadOnlyPrintMsg.htm)
suggest that this is possible, the version used here
(Office 2003 11.6359.6360 SP1) interprets all options also as part of the
filename, which then results in an "File not found".
This is the snipped from the article that describes the suggested changes to
the "Folder settings"-dialog (DOC filetype):
-----
Change the DDE Message to:
[REM _DDE_Minimize][FileOpen("%1",,1)][t=IsDocumentDirty()][FilePrint
0][SetDocumentDirty t][DocClose]
Note, you're really just changing the FileOpen code from [FileOpen("%1") to
[FileOpen("%1",,1)
Change DDE Application NOT Running to:
[FileOpen("%1",,1)][FilePrint 0][FileExit 2]
Note: same change.
-----
This just not works with the version here.
Any suggestions? Tag: add 28 days from present date Tag: 88929
find bold headings and add a return(or tab) after it
have a document like this...
1.0 Introduction(this is bold). Welcome to my document(first sentance of a
pragraph that isnt bolded text).
I need to put a return or a tab after the heading stuff thats in bold. Note
that some tables have bold headings centered on the page so perhaps a
condtion needed in the code to test for end of line(or text thats centered)
so it will skip that stuff
i have this from another post i found so maybe you VBA folks will have a
starting point to play with to help me out..thanks!
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
'**********************
.Text = "text" 'put your searched text here
.Replacement.Text = "^&"
.Replacement.Font.Underline = True
.Replacement.Font.Bold = True
'**********************
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll Tag: add 28 days from present date Tag: 88928
change default printer
I have an application that runs word in batch, and I want to change the
printer to use a duplex printer. Print the report, and change the printer
back to the default printer.
I created this template, which resides in templates directory, with a
shortcut residing in C:\Documents and Settings\Darrell Lee\Application
Data\Microsoft\Word\STARTUP
I have macros autoexec and autoclose in the template as shown below, but it
doesn't seem to be working. I could use some help.
Sub AutoExec()
'
' AutoExec Macro
' change to duplex printer
'
ActivePrinter = "\\swbc-pdw\Aficio2045-ELIC"
End Sub
Sub AutoClose()
'
' AutoExec Macro
' change back to original default printer
'
ActivePrinter = "\\swbc-pdw\LM410-ELIC"
End Sub
--
dlee Tag: add 28 days from present date Tag: 88927
Hyperlinking to a template containing VB from webpages
I'm probably missing something obvious here...
I've created some Word templates using VB and I want the users to be able to
link to them from our intranet site. However, if you open the template using
the link it opens the template itself rather than creating a new document
based upon the template.
Does anyone know how this could be fixed? Tag: add 28 days from present date Tag: 88925
Adding logos to document
I've concocted the following macro. The idea is that the user prints
the current document onto headed paper but then if they want to email
it (as an attachment) and therefore want the logo on the document the
macro fetches the "pictures" from another document.
1) It feels "cludgy". Is there a more elegant way of achieving this
result?
2) I've tested it on Word 2002. It will be installed (tomorrow?) on
Word 2003 - should I expect it to work?
3) There are around 30 users on a network who need access to it. Is
it better installed locally or on the network? I assume Gobal
templates is where it should go?
4) How do I find out what the picture numbers are? So far I only know
by recording a macro and then seeing the result.
Many thanks.
Sub Letter2Email()
'
' Macro1 Macro
' Macro recorded 25/05/2006 by anthonyl
'
Dim docSource As Document
Dim docDest As Document
Set docDest = ActiveDocument
Set docSource = Documents.Open("L:\letterheadwithlogo.dot")
' Application.Move Left:=115, Top:=25
' ActiveDocument.Shapes("Picture 2").Select
docSource.Shapes("Picture 2").Select
Selection.Copy
docDest.Activate
Selection.Paste
Selection.ShapeRange.IncrementLeft -1
Selection.ShapeRange.IncrementTop -10
docSource.Activate
ActiveDocument.Shapes("Picture 3").Select
Selection.Copy
docDest.Activate
Selection.Paste
Selection.Collapse
docSource.Close wdDoNotSaveChanges
End Sub Tag: add 28 days from present date Tag: 88923
PDF TO WORD
does anyone know of any piece of sw that can convert a pdf file to word
cleanly?
i have a document with lots of formatting and when i use Adobe 6.0 to
convert the pdf file to word all the formatting gets messed up.
or any ideas on how to make the pdf file editable?
TIA
Ted Tag: add 28 days from present date Tag: 88921
How to enable envelope in a protected document
I was wondering if somebody could help me finish this macro to work
correctly.
Basically what I'm trying to accomplish is to be able to run the envelopes
and labels with a protected document.
I found a macro to spell check a protected document and that worked great,
at http://word.mvps.org/FAQs/MacrosVBA/SpellcheckProtectDoc.htm
I then tried taking this macro and making it work for envelopes and labels.
I came fairly close, I can run the macro and the envelopes and labels dialog
box will pop up and if the user has a name and address it will bring that
into the envelope dialog box. If the user hits print it will print it
correctly and then close the dialog box and then protect the document. If
the user it's cancel they get an run-time error and the document doesn't get
protected.
Here is what I have and maybe if we can get this to work correctly maybe
this could be posted on the MVPS site for "How to enable envelopes and
labels in a protected document"
Option Explicit
Dim Cancelled As Boolean, MyRange As Range, CorrectedError As String
Sub WSNEnvelope()
'
' WSNEnvelope Macro
' Macro created 7/25/2006 by WSN
'
Dim oSection As Section, OriginalRange As Range, oDoc As Document
'If no documents open, quit macro
If Documents.Count = 0 Then
Exit Sub
End If
Set oDoc = ActiveDocument
Set OriginalRange = Selection.Range
System.Cursor = wdCursorWait
'Now unprotect the document
oDoc.Unprotect Password:="wsnforms"
Application.Run Macroname:="ToolsCreateEnvelope"
If Cancelled Then Exit Sub
'Re-protect the document
oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, _
Password:="wsnforms"
'oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
OriginalRange.Select
Application.ScreenRefresh
'Release variables from memory
System.Cursor = wdCursorNormal
Cancelled = False
CorrectedError = vbNullString
Set MyRange = Nothing
End Sub
Thanks
Brent Morris Tag: add 28 days from present date Tag: 88918
Move cursor to end of table of contents
Hi all,
I have a macro which adds extra text into the table of contents, but for it
to work correctly, the cursor needs to be placed at the end of the TOC. Is
there a way I can get word to place the cursor there automatically, rather
than making the user do it?
Thanks a lot,
TimDouglas Tag: add 28 days from present date Tag: 88915
Capturing Information via a User Form
I'm using a user form to capture fax information for a fax cover sheet.
1) Is the RANGE property the preferred means of grabbing info from a field
and placing it into a field on the user form?
ex:
frmFaxCover.txtPhone = Bookmarks.Item("fieldPhone").Range
2) What syntax would I use to grab the information from the User Form and
update the fields on the document? When I tried setting the .Range property,
the field was deleted completely. I'd prefer to simply update the field
preserving it.
David H Tag: add 28 days from present date Tag: 88912
generating a count of items in an array
I have an array (shown below as "varArr") in which a macro searches for terms
in the array ("text1", etc.) with a while statement. I occasionally add or
delete a term from the array. Is there any way of using UBound or something
else, to pick up the quantity of terms to be used in the array, so that I can
use a variable for that quantity instead of hard-coding it each time I add or
delete a term from the list?
varArr = Array("text1", "text2", "text3", "text4")
While intCnt < 5
~~
--
Bryan Tag: add 28 days from present date Tag: 88906
Word VBA Documentation
I don't have any documentation for Word VBA. Is it available for free
on the Internet? Tag: add 28 days from present date Tag: 88888
Run the Same Macro on Multiple Files
I'm proud of myself. I actually came up with a very useful Word VBA
macro without having to ask anyone how to do it:
Sub Macro2()
Dim theFileName As String
theFileName = Dir("C:\Temp\*.htm")
Do While Len(theFileName) > 0
ChangeFileOpenDirectory "C:\Temp\"
Documents.Open FileName:=theFileName
Application.Run MacroName:="Normal.NewMacros.Macro1"
ChangeFileOpenDirectory "C:\Temp2\"
ActiveDocument.SaveAs FileName:=theFileName, _
FileFormat:=wdFormatFilteredHTML
ActiveWindow.Close
theFileName = Dir
Loop
End Sub
This time-saving macro opens an .htm file in "C:\Temp", edits it by
running a macro called "Macro1", and then saves it as an .htm file by
the same name in folder "C:\Temp2". Then it automatically repeats the
procedure for all of the other .htm files in folder "C:\Temp".
I found out how to do the above for one file by recording a macro while
going through the procedure manually, but this didn't tell me how to
perform the operation on multiple files automatically. For that
information I did a search and found the following old posting on this
same amazing news-group (microsoft.public.word.vba.general):
http://groups.google.com/group/microsoft.public.word.vba.general/msg/0b1408cc4f19cd26
Hooray for Google Groups! I love you! Tag: add 28 days from present date Tag: 88887
Unprotecting Module
Is there a way when the password is known to unprotect a VBE project with
code, if so can someone assist me, please?
--
Mark Tag: add 28 days from present date Tag: 88878
using vba to delete part of a document
I've got a group of letters that are generated through a mail merge with an
excel file. These letters are to various entities and contain a listing of
specific incidents that they were involved in. Since I wanted to just have
one template and since the number of incidents per letter will vary, I
simply created a template that had X number of incident placeholders and
when the merge was performed, the placeholders were only populated up to the
number of incidents that particular entity had. For example, right now the
template has 39 placeholders because that happens to be the largest number
of incidents in any one letter. If I merge the data for an entity who has 6
incidents, then the resulting letter will contain those 6 incidents,
followed by 33 incident placeholders that contain no data.
Currently, I have to go back in to each letter and delete the "extra"
placeholders that are left over from the mail merge. (I know, I know..there
is probably a much easier way for me to do all of this from the outset, but
this is what I'm currently stuck with.) I've managed to place an identifier
in the excel file so that when the data is merged into letters, this
identifier is always found after the last incident in the letter...thus I
know that everything after the identifier until the language at the bottom
of the letter that is the same for all the letters can be deleted...that is,
all the rest of the incidents are simply blank placeholders.
What I would like to be able to do is create a macro that will go through a
letter and remove those placeholders for me. I'm thinking along these
lines, but I don't know how to make Word do this:
1. Find the identifier in the letter and move the cursor there.
2. Mark where the cursor is.
3. Find the beginning text at the bottom of the letter that marks the ending
of the incident placeholders and place the cursor at the beginning of the
paragraph.
4. Mark where the cursor is.
5. Now delete everything that is between the first and second marks.
Any ideas on how to accomplish this? Or possibly even a better way to go
about it?
-Brian Tag: add 28 days from present date Tag: 88876
VBA Referencing
reI have a template which I keep a lot of code in which is referenced to by
quite a number of other templates. I want to move the template which is
referenced to another location on my computer, this will obviously affect the
reference link. it is possible with code to alter all my templates so that I
don't have to open them myself one by one and change the reference path?
If so, would someone by kind enough to assist me with some code, please?
Thanks
--
Mark Tag: add 28 days from present date Tag: 88870
I need to add 28 days from todays date to a field.
ex: Todays date is 8/4/2006, in the next box (or field) I need to show 28
days from now which equals 9/1/2006.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Add 28 days from present date wrote:
> I need to add 28 days from todays date to a field.
>
> ex: Todays date is 8/4/2006, in the next box (or field) I need to
> show 28 days from now which equals 9/1/2006.