template macro
I asked about a macro for making a document open in
protected mode, with a custom toolbar showing. The
protection macro is working great. So does the toolbar
macro, as long as I'm opening the original template file
for editing. However, when using File New to create a new
document based on the template, the toolbar remains
visible or not depending on the last user's setting. Is
there a way to force it to be visible in a new document
based on the template?
Thanks in advance,
Helen Tag: Template macro question withdrawn Tag: 60067
Insert logo
Need a button (vba code) that inserts a logotype in a header (there is a
bookmark b in a table). When the logotype is inserted and the user clicks on
the button again it should not be inserted again. I also need the button
that will remove the picture (logotype) if the user wants to undo the insert
button. The documents can contain several pages, but the buttons should
insert / remove the logo on the first page only (regardless from where you
are in the document). Thanks for any help Tag: Template macro question withdrawn Tag: 60065
How can I view or print all the bookmarks in a word document at o.
I am using Word 2003 and would like to view or print all the bookmarks in a
document at one time.
In brief: I use these bookmarks in the code of a audit report automation
program (written in VBA for Word) and need to eleminate a document from which
the program calls. I would like to use some of the bookmarks in another
document and eleminate others. In the past I have had to write each bookmark
out on a piece of paper. This method allows room for a lot of errors. There
has got to be an easier way! Can any one help? Tag: Template macro question withdrawn Tag: 60063
Combining document with disparate styles
I'm working on a project where I'm automatically combining two or more
documents and I need to apply a consistent font throught the combined
document. The problem is that doc A may have a style named X that uses a
Helvetica font while doc B will have a style named Y that uses a Times Roman
font. I have to apply a common style, but first I need to determine if these
styles should be the same or if one is a heading style and the other a body
text style. And I also won't know at runtime what styles to expect from the
various documents I'll be assembling.
Is the only solution to this problem to iterate through all the styles in a
given document and do some basic heuristics on the discovered styles? For
example, look at the properties of style X and decide if it is a heading
style and then change the style a more generic style that is the best fit.
Or would it be simpler to just update the font of all styles to use a
pre-determined font family?
Any ideas would be greatly appreciated.
TIA
--
Peter Bernhardt
SharpSense Software LLC
peter@SharpBASSense.netURA Tag: Template macro question withdrawn Tag: 60062
adding data to an embedded chart dynamically
All,
I've created a word document that contains an embedded chart (using Insert >
Picture > Chart) The chart's layout optin is "In front of text".
What I'd like to do change/modify the data in the datasheet of this chart
using vba or vbscript, but I don't know how to reference it.
I've done the same thing in PowerPoint with this:
Set oApp = CreateObject("Powerpoint.Application")
Set oPres = oApp.Presentations.Open("C:\Presentation.ppt")
Set oSlide = oPres.Slides("slide1")
Set oChart = oSlide.Shapes("chart")
with (oChart..OLEFormat.Object.Application.DataSheet)
.Range("A1").Value = 100
End With
But I don't understand the object model of word well enough to do this in
Word. I also don't know how to name objects in Word so that I can reference
them.
Many thanks in advance for any insight or advice!
Cheers,
Matt Stuehler Tag: Template macro question withdrawn Tag: 60060
Merging two documents
A friend of mines asked me to help him with this project. We have two
separate word documents. MovieTitles.doc and MovieInfo.doc
Movietitles is just a document with movie titles formatted as follows:
Godfather
Speed
Matrix
etc.
MovieInfo contains movie information such as:
Godfather
A cinematic classic depicting the lives of ....
What we'd like to do is open both of these documents behind the scenes. If
we have matching titles we want to create a third document that includes the
movietitle from movietitles.doc and underneath the title we want to indent
and include all of the movieinfo from the movie info from the movieinfo.doc
We want the text bold and changed to the color blue. Finally we'd like to
save this as a third document. So far they've been doing this manually. in
my mind this process is screaming for automation. Any advise with this
process is welcome. Thanks in advance.
Malik Tag: Template macro question withdrawn Tag: 60058
Margins of section xx error message
Hi,
I am using Word automation to print documents to a PDF driver and on some
documents I am having a problem with the "Margins of section x lie outside
the printable region".
The problem I have is that I only get this on some machines (the ones I need
to use!) and not on others. For example on a Win 2K machine with Word 2003
installed I get the error, but if I take the same document to an XP machine
with Word 2003 installed the document prints OK to the same PDF driver.
Changing to an alternative suppliers PDF driver does not cure the problem.
I have tried changing normal.dot do that it is the same on both machines but
this has no effect.I have made sure Page Setup has no margins, etc,etc.
The PDF drivers are the same on both machines, Word has the same Service
Pack level.
This is driving me crazy as the production machines for this all need to be
Windows 2K.
Does anyone know what settings Word takes into account when produciing this
message ?
From trawling the Newgroups it appears that this helpfull message can not be
supressed. Is this correct ?
Thanks
Iain Hamilton Tag: Template macro question withdrawn Tag: 60056
Control Firefox via VBA
Hi
Is it possible to control Firefox 1.0 via Word-VBA?
I wrote some neat tools for the IE using MSHTML and SHDocVw which I
want to make it also work with Firefox, especially because of its
tabbed browsing.
I have allready googled through the net but I couldn't find a Module
or library to bind into Word-VBA.
Anyone out ther who has a clue?
thx Itekt Tag: Template macro question withdrawn Tag: 60055
word document
I am using windows 98SE Plus and recieved an email attachment that is word
document but everytime i go to open it it tells me that it has performed an
illegal operation and must close. How do i remedy this problem Tag: Template macro question withdrawn Tag: 60049
BREAK & CONTINUE...
Hi All
I am using Msword 2003 and its VBA
Q1 : Could you please let me know how can i use continue statement as in VB .?
Also,i have used several tab options in a multi page control and want to
traverse through all the contols present in that multipage.
Q2 :How can i traverse thorugh all the controls in the multipage in one go.?
I could only get the "controls " property with the frame control, to use.
Thanks for help.
Alok. Tag: Template macro question withdrawn Tag: 60038
Split Directory\filename into two variables
In my macro a user selects a filename using:
With Dialogs(wdDialogFileOpen)
If .Display Then
strSourceFile = WordBasic.FilenameInfo$(.Name, 1)
End If
End With
I want to split strSourceFile into a directory part, and a filename
part. I've done this before by starting at the left most point of a
string, then backing up one character untill a backslash is found, but
I think there is probably something all ready built into VBA to do this. Tag: Template macro question withdrawn Tag: 60036
wdSaveChanges doesn't work
I am using ActiveDocument.Close SaveChanges:=wdSaveChanges
But I still get a prompt asking me to save changes. Any help would be
nice. Tag: Template macro question withdrawn Tag: 60029
Wild Card Search II
Helmut, et al,
Sorry for reposting this, but the initial post is around 2-3 weeks old and
buried. I was afraid it wouldn't get any attention. Here it is:
Helmut,
Hi, I am sorry this is so delayed, but I got caught up in some other
work before I could test the macro you supplied me. When I run the
macro, it gives me an error that says, the Find What contains a
Pattern Match that is not a valid Expression. Do you know what this
means or why I am getting this error?
Here is the code clipped from the larger macro:
ResetSearch
With Selection
.ExtendMode = False
.HomeKey unit:=wdStory
With Selection
.ExtendMode = False
.HomeKey unit:=wdStory
With .Find
.Text = "(^13)([A-z]{1;}.[^32^s^t]{1;})([!^13]{1;})"
.Replacement.Text = "\1\3"
.MatchWildcards = True
' define formatting
.Execute Replace:=wdReplaceAll
End With
End With
TIA,
Jason L
Helmut Weber <elmkqznfwvccbf@mailinator.com> wrote in message
news:<agosp0l7nsg9kphkv1dbag2am70mkvbj5a@4ax.com>...
> Hi Jason,
> keep on!
> > With Selection.Find
> > .Text = " [ A-z].[^32^s^t]@"
> > .Replacement.Text = "1/^+"
> hm..., doesn't make any sense to me.
> The 1/ should probably be \1, but would require an expression
> inclosed in parenthesis (). Apart from other complications,
> and apart from the fact, that wildcardsearch needs quite a bit
> of a trial and error approach, (and some things simply don't work),
> here is what i've figured out:
> Search for a paragraph starting with some letters followed by "."
> (^13)([A-z]{1,}.)
> Paragraph would be expression \1 later.
> Instead of {1,} one should be able to use @, but doesn't work here.
> Include whitespace after ".":
> (^13)([A-z]{1;}.)([^32^s^t]{1,})
> Again, ^w for whitespace doesn't work, therefore [^32^s^t]{1,}.
> As the characters and the whitespace can be grouped together,
> we arrive at:
> (^13)([A-z]{1,}.[^32^s^t]{1,})
> Now we got to search until the paragraphs end.
> That would be one ore more characters, that are not chr(13).
> ([!^13]{1,})
> All together it could look like:
> "(^13)([A-z]{1,}.[^32^s^t]{1,})([!^13]{1,})"
> So we got 3 expressions,
> expression1 is the preceding paragraph mark, which we leave untouched,
> expression2 is
> the letters following, plus the period plus the whitespace
> expression3 is the remainder.
> Follows
> .Replacement.Text = "\1\3"
> which means "cut off expression \2".
> Apply the formatting to the result.
> Here is my test macro, which could be improved by using
> range instead of selection, and in some more ways, I guess.
> Sub Test661()
> ResetSearch
> With Selection
> .ExtendMode = False
> .HomeKey unit:=wdStory
> With .Find
> .Text = "(^13)([A-z]{1;}.[^32^s^t]{1;})([!^13]{1;})"
> .Replacement.Text = "\1\3"
> .MatchWildcards = True
> ' define formatting
> .Execute Replace:=wdReplaceOne ' for testing
> End With
> End With
> ResetSearch
> End Sub
> Public Sub ResetSearch()
> With Selection.Find
> .ClearFormatting
> .Replacement.ClearFormatting
> .Text = ""
> .Replacement.Text = ""
> .Forward = True
> .Wrap = wdFindContinue
> .Format = False
> .MatchCase = False
> .MatchWholeWord = False
> .MatchWildcards = False
> .MatchSoundsLike = False
> .MatchAllWordForms = False
> .Execute
> End With
> End Sub
> HTH
> Greetings from Bavaria, Germany
> Helmut Weber, MVP
> "red.sys" & chr(64) & "t-online.de"
> Word XP, Win 98
> http://word.mvps.org/ Tag: Template macro question withdrawn Tag: 60022
InsertFile method leaves certain text out after insertion.
I am using the InsertFile method to insert the contents of a text file into a
Word document, like so:
.Selection.InsertFile TextFileName, Range:="", _
ConfirmConversions:=False, link:=False, _
attachment:=False
I have found that certain text is left out after insertion by Word, e.g.
"+/-". When I try the insert file command from Word itself, a confirm
conversion box will pop up, and allow me to force a "Plain text" conversion,
which in turn leaves in the missing text after insertion. However, I cannot
find a way to force this programmatically.
Wd 2k, '03; Win XP, 2000
Any assistance would be appreciated.
Thanks. Tag: Template macro question withdrawn Tag: 60019
VBA Checkbox Problem
I am dynamically creating checkboxes at runtime and
trying to set the bookmark name. However, it will not
allow me to set the new checkbox. I have tried
dynamically changing the name of the bookmark, deleting
it, and renaming. Nothing seems to work. Any help or
work around would be appreciated Tag: Template macro question withdrawn Tag: 60016
autoexec error
I getting an error when I start MS word or Ms excel that the hidden macro
Autoexec has an error. Can someone tell me how to get rid of this error. I
can't find an autoexe macro.
Thank Mark Tag: Template macro question withdrawn Tag: 60015
Text Selection with VBA
Hello, I am new to VBA in Word and I was wondering if=20
someone could help me please!
I have a string in a Word document that I want to copy=20
from Word and then copy to an Excel worksheet. But the=20
string has a hard return at the end of it. So how do I=20
copy from the beginning of the string to the hard return?=20
I know the position in the document that the string starts=20
at but I do not know how to copy only to the carriage=20
return. For examle, when you select "Show/Hide =B6" to Show=20
it looks like:
125 North Street=B6
How do I use VBA to select only up to the hard return? I=20
hope this makes sense. Any help would be appreciated.
Thanks. Tag: Template macro question withdrawn Tag: 60011
alphabetize mail merge
I am developing a mail merge catalog in Word and using a query in Access as
my data source. The table that the query references in Access is
alphabetized by last name, the query in Access is alphabetized by last name,
but the mail merge catalog prints in the order that the records were entered,
rather than alphabetical order.
How can I get the mail merge catalog to print in alphabetical order? Tag: Template macro question withdrawn Tag: 60007
Range Object positioning trouble
Hi everybody!
I've got some troubles, working with Range:
Here is a code context:
..
Call Word.ActiveDocument.Bookmarks.Add("A" & CStr(iter),
Word.ActiveDocument.Range(bmStart, bmStop))
..
bmStart and bmStop are changing from 0 to ActiveDocumet.Characters.Count,
and mark parts of the document with different formatting.
For the majority of test documents that works perfectly: I get Bookmark
from Character # bmStart (incl) to Character # bmStop (incl), but for the
moment I've got a document, for which from the very beginning of the
document it works as Range from Character # (bmStart - 1) (incl) to
Character # (bmStop - 1) (incl). Any specific features about this very
document I've not found. Why could it be?
Thanks, Alex Tag: Template macro question withdrawn Tag: 60002
Lock module sperately
Hi,
I am using modules in wod vba project.
I want to lock project code & module which is inside the project in
seperate password. Does this possible. IF so , may I have any solution.
Currently If I unlock project user can access any modules, but I want to
restrict
acess to each module by password.
Thanks & Regards
Naveen Tag: Template macro question withdrawn Tag: 60000
Let there be an option for ignore once for spelling mistakes
When i'm writing somethign in Word and i make a mistake then there should be
an option to ignore once. The only option when i right click is to ignore
all. I think there should be an option to ignore once. It owuld also help
because if someone accidently clicks it then they can easily fix it where as
if they accidently click ignore all then they ahve to search the document for
all the words they mis spelt. Tag: Template macro question withdrawn Tag: 59999
How to handle add-in clash
I've just discovered that a template I distribute is clashing with
Acrobat 6. When someone who has installed Acrobat 6 and its Word
add-in creates a document based on my template, all is fine.
But when that user saves the document, and then reopens it, my menu
doesn't display, even tho I have code in my auto-open routine to
display the menu if it isn't on the menu bar.
When such users disable the Acrobat add-in, all is fine. So there's
clearly a clash with something Acrobat is doing, but I don't know what
that is.
Question: is the appropriate way to handle this clash to have my
autoopen function unload the Acrobat add-in, or is there some better
way to handle this?
thanks,
gary Tag: Template macro question withdrawn Tag: 59998
>> Macro buttons
Hi, I have a template the includes two macro buttons, each
with code. The idea is that a user will choose one button
to remove content.
When a new document is created from the template there is
no code for each of these buttons. When I check the
template the code still exists for these buttons.
How can I set up this template so that these buttons
actually have code?
Any ideas or suggestions appreciated :-)
Cheers
Jonathan Tag: Template macro question withdrawn Tag: 59996
List template funkiness in Word 2003
At work, we are in the process of switching from Office 2000 to Office 2003.
Part of that process is making sure that all of the macro solutions we use
with Word will operate correctly under Office 2k3. Problem is, they don't and
I can't quite figure out why. Here's the setup...
Originally started in Word 97, we have a set of macros that provide the user
with a choice of templates to use with their documents. These templates all
have different body text styles, heading styles, TOC styles, outline
numbering styles, etc. The users have the ability to switch templates from a
drop down menu in a toolbar and all of the styles in their document will
change accordingly. It was tought to get it so that the numbering would
change correctly, but we finally got it working and it's worked fine now for
2+ years.
Under Word 2k3, however, not everything works the way it should.
Specifically, the outline numbering associated with the heading styles does
not switch when the user selects a different template. Or rather, it switches
properly sometimes, other times it doesn't switch at all or switches to an
incorrect numbering style.
When we set up the templates and styles, we defined the outline numbering
through the style definition rather than through the Numbers and Bullets
dialog because everything I'd found on the net said to avoid the latter and
just define the numbering as part of my styles. After some tweaking and
banging my head against my desk, I actually got it to work quite well.
My question is this: Did something change internally that might affect this
process? It works fine in Word 97 and Word 2000, but falls to pieces in Word
2003. I remember having to code around problems when we moved to 2k, so maybe
there's some change I'll have to account for in 2k3? Tag: Template macro question withdrawn Tag: 59994
Sorry!!!
My previous post was posted on the wrong group. I had the wrong group
selected when I created the message and didn't pay attention.
Sorry! Tag: Template macro question withdrawn Tag: 59993
Print a picture Box Image
Dear Group
I have created a scrollable picture in my application, ie a picture box as a
member of another picture box, a couple of scroll bars and now I have a
scrollable bitmap image larger than my screen. I would now like to be able
to print it but the only example of how to do this is Q230502 - How To Print
a Form That Is Too Large for the Screen or Page.
By following this example with my setup picture box within picture box, I
can only print the visible area and not the entire picture. When I follow
the example in the exercise it works, however the picture boxes are separate
and not with one as a member of another.
Can I print the entire bitmap image in my setup? The article states that:
Because the PictureBox's bitmap is stored in a device context in memory, you
have access to the entire bitmap regardless of what is displayed.
Is this still true in my current setup? If it is not possible can the group
think of a workaround?
Thanks again...
Kagsy Tag: Template macro question withdrawn Tag: 59992
Serial numbering of documents in a networked environment
I would like to know the recommended method of inserting an automatic
"serial" number in a document. An example of this would be a company-wide
outgoing fax serial number.
I realize that it is rather big, in the sense that it could include many
issues (what kind of field should be used, how do we keep the user from
altering it and so on).
Since I have a background in DOS programming, I am primarily interested in
the file functions and locking mechanism necessary to save and retrieve the
serial number from an external file, since we are operating in a networked
environment.
Any help is welcome. Thanks in advance. Tag: Template macro question withdrawn Tag: 59991
How do I convert a file from MS-DOS Works?
My husband has his client christmas card label list on a floppy that I think
was saved from an extremely old version of Works. It is set up in fields,
and so far I've been able to access the names and addresses in only the
vertical 'field' format. How can I convert this file so that the correct tabs
will apply?
Thanks Tag: Template macro question withdrawn Tag: 59989
Returning selected shape from within drawing canvas
I'm trying to determine the name of the currently selected shape
within a drawing canvas, but all I get is the name of the canvas
itself.
MsgBox Selection.ShapeRange.Item(1).Name
MsgBox Selection.Range.ShapeRange(1).Name
This all returns the name of the drawing canvas, although only one of
the shapes within the canvas is selected.
MsgBox Selection.ShapeRange(1).CanvasItems(1).Name
Returns the name of the first added shape in the canvas and that's not
necessarily the currently selected shape. Does anyone have any
suggestions?
Thanx, Fabian. Tag: Template macro question withdrawn Tag: 59988
Formatting individual paragraphs in a Cell
I'm stuck.
I'm writing a few one-line paragraphs into a table cell (actually a
label in a word-created blank labels document). All of the text is
aligned left. But for a few cells, I want to add an additional
one-line paragraph that's aligned right and italicized. But whatever
I try ends up formatting the whole cell as right aligned and
italicized.
I want the label to look sorta like this:
First Name Last Name
Address
Department
Specialty Text
Does anyone know a way to format the last paragraph of a cell without
it affecting the whole cell?
Here's my latest attempt that still didn't work.
Dim rng As Range
Set rng = ActiveDocument.Tables(1).Cell(nRow, nColumn).Range
With rng
.InsertAfter "Specialty Text"
.Previous wdParagraph
.Expand wdParagraph
.Font.Italic = True
.Select
.ParagraphFormat.Alignment = wdAlignParagraphRight
End With Tag: Template macro question withdrawn Tag: 59987
Can't use word wrap in Word 2000 macros
When I try to use the "Record New Macro" system in WD2000 to change an
in-line picture to be text-wrapped, the text wrapping options in the picture
formating dialog are grayed out. There is a tech note that describes a
similar problem (WD2000: Unable to Record Macro for Inline-to-Floating
Picture Conversion; Article ID : 209800)that says the work around is to
select the picture, cut it, then paste-special as a picture, then select it
and change the wrap option. This doesn't work (at least not in Word 2000 on
Wuindows 2000).
Is there a work around or a way to actually code this in the macro editor? Tag: Template macro question withdrawn Tag: 59978
Macro for opening
I want to write a macro that will cause two things to
happen when that specific document is opened, no matter
how a previous user left it. I want a certain custom
toolbar to be visible, and the document to open in
protected mode. Any ideas? My brain is turning to rubber
here...
Thanks! Tag: Template macro question withdrawn Tag: 59973
Calling Otherproject.Sub from Normal.ThisDocument
Two questions, really.
I've got my macros in "MyMacros.dot" startup template. But I
need some of them in my Normal.ThisDocument
Document_New/Open/Close routines.
Haven't been able to call them out of the MyMacros project with
any variation of syntax ([MyMacros.vbp].[Utils].DoSomething).
So, I've had to copy some of them over to a local module in
Normal which seems kind of silly and redundant.
Is that because you just can't call out of project from
ThisDocument or because I just don't know how to do it?
(sorry 'bout the cross post but traffic is light over in my
beginner corner)
--
Poseur
"That's just kooky talk." --Kramer Tag: Template macro question withdrawn Tag: 59972
Delete VBA code in runtime
Hi,
I have the below code in ThisModule of severel templates. It calls and
add-in that do some stuff.....
Now I would like the finished documents to be without code in ThisModule, so
that when a user mails the documents to a customer or.... the documents will
not be stopped in AntiVirus systems, that does not allow VBA code.
Can I delete all the code in ThisModule in run-time ?
Thanks,
Flemming
-----
Private Const msNAME As String = "EN.dot"
Private msFullFileName As String
Private Sub Document_New()
' Code
' Code
'DELETE IT ALL........
End Sub
Private Function FileExists(ByRef sFullPathAndFileName As String) As Boolean
' Returns True if the file exists
FileExists = CBool(Len(Dir(sFullPathAndFileName)))
End Function Tag: Template macro question withdrawn Tag: 59968
adding bookmarks stop without message why
I have a document directory that consists of word documents and a table of
contents that relate to those documents. So I thought I would create
bookmarks as they relate in the table of contents. Then create adobe acrobat
pdf from that.
Well I had to modify the bookmarks with _ and some search fields. So I
massage them with c language. The following code works with the files I
created with C language.
The problem is that I can only create 9 bookmarks and the program finishes
prematurely without giving me a message why.
When I check out in word 2000 with inserting bookmarks I find the 9
bookmarks there but the dropdown box v isn't available. It can't add more
bookmarks .I also tried this code also :
"ActiveDocument.Bookmarks.ShowHidden = True
For Each aBookmark In ActiveDocument.Bookmarks
If Left(aBookmark.Name, 1) = "_" Then MsgBox aBookmark.Name
Next aBookmark
It ends up with the same unfilled record count. I know that there is at
least 12 more _ items to add with the above code by dies with just 9 records.
There is nothing wrong with files I've create
Heres my code below
Do While Not EOF(1)
Line Input #1, searchstring
Line Input #2, bookmarkfield
Set MyRange = ActiveDocument.Content
MyRange.Find.Execute findText:=searchstring, Forward:=True
If MyRange.Find.Found = False Then Exit Do
ActiveDocument.Bookmarks.ShowHidden = True
ActiveDocument.Bookmarks.Add Name:=bookmarkfield, Range:=MyRange
ActiveDocument.Bookmarks.ShowHidden = True
Rem MyRange.Bookmarks(counter).Add Name:=bookmarkfield
ActiveWindow.View.ShowBookmarks = True
primenumber = 0
counter = counter + 1
Loop
offset = offset + 1
Close #1
Close #2 Tag: Template macro question withdrawn Tag: 59963
adding bookmarks stop without message why
have a document directory that consists of word documents and a table of
contents that relate to those documents. So I thought I would create
bookmarks as they relate in the table of contents. Then create adobe acrobat
pdf from that.
Well I had to modify the bookmarks with _ and some search fields. So I
massage them with c language. The following code works
with the files I created with C language.
The problem is that I can only create 9 bookmarks and the program finishes
prematurely without giving me a message why.
When I check out in word 2000 with inserting bookmarks I find the 9
bookmarks there but the dropdown box v isn't available.
It can't add more bookmarks .I also tried this code also
"ActiveDocument.Bookmarks.ShowHidden = True
For Each aBookmark In ActiveDocument.Bookmarks
If Left(aBookmark.Name, 1) = "_" Then MsgBox aBookmark.Name
Next aBookmark "
It ends up with the same unfilled record count. I know that there is at
least 12 more _ items to add with the above code by dies with just 9 records.
There is nothing wrong with files I've create
Do While Not EOF(1)
Line Input #1, searchstring
Line Input #2, bookmarkfield
Set MyRange = ActiveDocument.Content
MyRange.Find.Execute findText:=searchstring, Forward:=True
If MyRange.Find.Found = False Then Exit Do
ActiveDocument.Bookmarks.ShowHidden = True
ActiveDocument.Bookmarks.Add Name:=bookmarkfield, Range:=MyRange
ActiveDocument.Bookmarks.ShowHidden = True
Rem MyRange.Bookmarks(counter).Add Name:=bookmarkfield
ActiveWindow.View.ShowBookmarks = True
primenumber = 0
counter = counter + 1
Loop
offset = offset + 1
Close #1
Close #2
End Sub Tag: Template macro question withdrawn Tag: 59962
Maximum Doc Var's
Hi
Could you please let me know
"THE MAXIMUM NO. OF DOCVARIABLE THAT A WORD2003 CAN STORE"
Thanks
Alok Tag: Template macro question withdrawn Tag: 59961
Class Module for Save Events
Word 2000
I've been experimenting with my first class module. Here's what I have:
Class Module
==========
Public WithEvents App As Word.Application
Private Sub App_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As
Boolean, Cancel As Boolean)
If ActiveDocument.Name = "Locates.doc" Then SaveDocument
End Sub
Private Sub SaveDocument()
ThisDocument.SaveFile
End Sub
Standard Module
============
Dim X As New clsSaveEvent
Private Sub Document_Open()
InitializeSaveEvent
End Sub
Sub InitializeSaveEvent()
Set X.App = Word.Application
End Sub
Sub SaveFile()
< Some code >
End Sub
So the event gets initialized when the document is opened. Each time a save
event occurs the code in the class module runs, and if the document name is
"Locates.doc" then SaveDocument, and finally SaveFile are called. This
seems to work rather well, but being a class module newbie, I have several
questions. I hope no one minds that I'm piling all these questions into one
message, but they are all related to the same issue, so I figured that it
would be easier this way.
1) The event works at the application level, and I want it to run only in a
specific document, which is why I have the App_DocumentBeforeSave routine
testing for the document name. I tried putting
Set X.App = Word.ActiveDocument
in the InitializeSaveEvent routine with
Public WithEvents App As Word.Document
in the class module. No errors occur with these lines in place, but at the
same time, nothing appears to happen when I save the document. Is there a
way to make this work only at the document level?
2) The event gets initialized when the document is opened, but I've noticed
that after changing code in the module, I often need to initialize the event
again. It makes sense that if the code in the event is changed, you'd have
to reinitialize the event. However, is it possible that other changes, such
as changes to the document or template, might also require the event to be
reinitialized?
3) My experience with forms in Access, Excel, and Word have taught me that
it's easy to end up with looping code when using before and after events,
and that makes me a little leery here. What are the drawbacks, if any, of
using the App_DocumentBeforeSave?
4) While the code above basically works, there is an annoyance that I have
yet to solve. Say that the user does a Save As. The code will run as
expected, but when the code completes the Save As dialog box will be
displayed. I don't want that because I'm trying to control how the document
gets saved, and I don't want the user to be able to change the name or the
location of the file. Is there a way to prevent the Save As dialog box from
being displayed (I read in the Help that the return value for the Cancel
button is 0, and I thought maybe that could somehow be used to suppress the
Save As dialog box, but I'm not sure how that would work)?
5) This is somewhat related to question 4. Is there a way to disable the
Save As option in a specific document (not application-wide)?
Any information that you may be able to provide will be greatly appreciated.
-- Tom
State of Montana
Department of Justice Help Desk
"Making the world a safer place." Tag: Template macro question withdrawn Tag: 59956
Highlighting bookmark text
I am working on a macro that will get info from the user and insert it at a
bookmark in the document text. If the user doesn't enter info, I want to
provide reminder text for later editing (but I don't want this to appear as
default text in the input box), AND I'd like to highlight the reminder text.
Sample code is:
' Get the mailing and receipt dates from the user;
MailDate1 = InputBox(MailMsg & Doc1)
' If no user input, define and format help text
If MailDate1 = "" Then
MailDate1 = "ENTER MAILING DATE"
End If
' Go to the bookmark and enter the date
.Bookmarks("Mail1").Range _
.InsertAfter MailDate1
Is there a way to easily highlight the help text without doing a
find/replace or similar action?
Thanks much in advance. Enjoy your weekend! Tag: Template macro question withdrawn Tag: 59951
Deleting all Instances of Captions
I have tried the attached which I had found on a recent search of this group
but it does not seem to delete all the captions but rather hangs up at "for
each acap in activedocument" stating that this object does not support this
property or method.
I am trying to delete all inline shapes and their corresponding captions
from a document - I have figured out the inline shape bit but the caption
part is a problem.
Any ideas would be welcome.
Dim acap As CaptionLabel
For Each acap In ActiveDocument
acap.Delete
Next acap
Thanks
David Tag: Template macro question withdrawn Tag: 59949
Problem building a COM Add-in for Word 2003
Folks,
After building a VBA macro for Word 2003, I want to convert it to a COM
Add-in so I can distribute it. I do not know if this is the correct group
in which to post this question, but I'll start here.
I followed the excellent example, "Converting Microsoft Office VBA Macros to
Visual Basic .NET and C#," which I found at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnofftalk/html/office11072002.asp
This shows how to build a COM Add-in for PowerPoint. I followed the example
and it works like a charm.
But when I do the same thing to build a COM Add-in for Word, it is never
activated. I set a breakpoint at the OnConnection subroutine and the code
never breaks.
It's one of those things that makes me go "hmmm....."
Any help would be appreciated, including a suggestion for the proper group
in which to ask this in the event that this is not the proper one.
/Joel Finkel
finkel@sd-il.com Tag: Template macro question withdrawn Tag: 59947
summarise document contents
Dear Group
How in Word can I loop through a document and get the dimensions and
position of every object on the page, be it paragraph, rectangle, line, etc.
I can loop through text and paragraphs as below, but I need all objects on a
page.
Dim para As Paragraph
For Each para In ActiveDocument.Paragraphs
****
Next
What I really want is the Left, Top, Height and Width of the object and the
TypeOf object it is.
I have over 50 documents of 5 or more pages looking like forms (30 Boxes and
lines) that I want all the measurements so I can take these measurements and
create the same objects in a VB form. My aim is to create a converter. I
fully appreciate that the same objects do not exist in VB so I will use
CreateControl to create the comparable desired objects.
I realise this is a mammoth project but I would appreciate any pointers from
the group as to where to start.
Please help whilst I still have some hair!
Alastair MacFarlane Tag: Template macro question withdrawn Tag: 59946
Format Text Box Before outputting it
New to VBA for word though I have some experience in VBA for Access.
I want to place formatted text boxes on a document . If I use something like
Sub DrawTextBox()
ActiveDocument.Shapes.AddTextbox _
(msoTextOrientationHorizontal, 100, 100, 100, 80).Select
Selection.ShapeRange.Select
With Selection.ShapeRange
.TextFrame.MarginLeft = 0#
.TextFrame.MarginRight = 0#
.TextFrame.MarginTop = 0#
.TextFrame.MarginBottom = 0#
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor = RGB(255, 0, 0)
.Fill.Transparency = 0#
.Line.Transparency = 0#
.Line.Visible = msoTrue
.Line.DashStyle = msoLineSquareDot
.Line.Weight = 5
.Line.Style = msoLineSingle
.Line.ForeColor = wdBlue
End With
With Selection.Font
.NameAscii = "Arial"
.Size = 16
.Bold = True
.Italic = False
.Underline = True
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = RGB(0, 0, 0)
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
' Center
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.TypeText Text:="This is a Text Box"
Selection.Collapse
End Sub
The problem is that each bit of formatting takes place sequentially, and
outputting 50 or 100 text boxes takes a few minutes to complete
I feel there should be a way of defining the text box properties BEFORE
Adding it to the document
Something like (I know none of this works)
Dim MyTextBox as TextBox
With MyTextBox
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor = RGB(255, 0, 0)
.Fill.Transparency = 0#
.Line.Transparency = 0#
.Line.Visible = msoTrue
.Line.DashStyle = msoLineSquareDot
.Line.Weight = 5
.Line.Style = msoLineSingle
.Line.ForeColor = wdBlue
End With
Set MyTextBox = ActiveDocument.Shapes.AddTextbox _
(msoTextOrientationHorizontal, 100, 100, 100, 80)
This seems to work as another alternative UNTIL I get to trying to output it
to the document
Public Type MyTextBox ' Create user-defined type.
FillColour As Long ' Define elements of data
type.
BorderColour As Long
BorderWidth As Integer
ForeColour As Long
End Type
Function CreateTextBox()
Dim MTB As MyTextBox ' Declare variable.
Dim MyDocument As Document
Dim MyTB As TextFrame
Dim TextBox1 As Shape
Dim NewShape As Shape
With MTB
.BorderColour = wdBlack
.BorderWidth = 6
.FillColour = RGB(255, 0, 0)
.ForeColour = wdWhite
End With
??????????????? Output
Thanks for any help
Phil Tag: Template macro question withdrawn Tag: 59941
modify calendar wizard
Word 2000 (9.0.6926 SP-3). How can I modify the default font in calendar
wizard for the Days of the week and the numbers for the days. I also want to
set the default to left justify the numbers of the days. Tag: Template macro question withdrawn Tag: 59939
printing envelopes
I am using Windows XP and have an injet Lexmark printer - for some reason all
of a sudden I cannot print envelopes. Can someone help? When I print
envelopes I get a blank page - I can print documents but not envelopes. Tag: Template macro question withdrawn Tag: 59938
Cannot create word.application with word 2003 basic
Is it possible to automate word 2003 basic using create
object("word.application"). I'm trying to automate word through Visual Foxpro
8.0. It appears that createobject("Word.Basic") works fine but I get an
error when creating the application object. Tag: Template macro question withdrawn Tag: 59937
From mysql to word
Hi, how could i export data from mysql data base into a word's template?
Thanks in advantage.
Claudia Tag: Template macro question withdrawn Tag: 59936
Searching for sections for primary footer
Begining with the first section, I need to search through
the sections for the first section that has an odd page
footer (each section is set for different first page and
even and odd page footers). When the first odd page
footer in the document is reached I can stop the search
and perform some actions in that footer.
I can't simply use something like:
With Selection.Sections(1).Footers_(wdHeaderFooterPrimary)
because I am inserting a textbox in the footer, and this
will not allow that because it essentially opens the
footer in normal view, and I need to be in the footer in
print layout view, as in:
ActiveWindow.View.SeekView = wdSeekPrimaryFooter
Thanks for the help Tag: Template macro question withdrawn Tag: 59935
Lost file password
OK I have lost the password to a bunch of word files that I NEED to get
into..is there some way of getting in a backdoor or converting it in some way
to get them open?? Help me please Tag: Template macro question withdrawn Tag: 59934
Sorry, I figured this out from another post, works great.
I think I'm getting a book...