section add - insert file
I have tried this code and it works well if I select one checkbox. If I
select more than 1, it is not working correctly.
My template is a letterhead (top and bottom) as are my documents.
When I check box one, it adds temp2.doc correctly.
When I check box 2, it adds a blank letterhead after my template page, then
adds
temp3.doc as a continuation of temp2.doc rather than starting a new page.
I have in chk2 named myDoc1 and docrange1 but, that did not help
Here is the code for each check box:
Sub chk1()
'
' chk1 Macro
' Macro created 4/10/2008 by bjsorens
'
If ActiveDocument.FormFields("Check1").CheckBox.Value = True Then
Dim myDoc As Document
Dim docrange As Range
Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = Selection.Bookmarks("\Page").Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "u:\temp2.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With
End If
End Sub
Sub chk2()
'
' chk1 Macro
' Macro created 4/10/2008 by bjsorens
'
If ActiveDocument.FormFields("Check2").CheckBox.Value = True Then
Dim myDoc As Document
Dim docrange As Range
Set myDoc = ActiveDocument
With myDoc
.Unprotect
Set docrange = Selection.Bookmarks("\Page").Range
docrange.Collapse wdCollapseEnd
docrange.InsertBreak wdSectionBreakNextPage
Set docrange = .Range
docrange.Collapse wdCollapseEnd
docrange.InsertFile "u:\temp3.doc"
.Protect wdAllowOnlyFormFields, NoReset
End With
End If
End Sub
Would appreciate any help so that by checking more than 1 box, the next file
(document) added would append after the last.
Thanks,
Bryan Tag: Font of toolbar Tag: 112405
Localize my VBA?
Does anyone have any tips or links to information about localizing my VBA
code? So far it's been running in North America and Australia, where some
form of English can be selected from the Regional Options, and where an
English keyboard is in use.
Now I'm going into Spain, and aside from a different keyboard layout, some
macros seem to stumble. Here's the most common error message:
The Find What text contains a Pattern Match expression which is not valid.
I'm also wondering how I should handle the different delimiters used in
numbers (decimals vs. commas). Date formats aren't a big problem yet.
Can I detect the language settings in VBA?
Bear
--
Windows XP, Word 2000 Tag: Font of toolbar Tag: 112404
Word as HTML editor
I have set up a document management app and plan to use Word as an HTML
editor for my users. A user can click on a button to open the displayed .htm
file in Word and make minor edits if needed. I also include delimited field
names in the html document to allow a merging of data.
My problem is that, if they have automatic spell or grammar checking on, or
automatically suggest new spelling on, Word places characters around each
misspelled word. When the file is printed from my app, a merge process runs
replacing field names with that field value. But my merge process is
confused by these characters. Mostly, this confusion is caused by the
characters separating a line, or separating a field name across lines, making
it impossible to recognize the field name in order to replace it.
I have tried locating and removing the spell check characters before running
the merge, but this has not worked effectively.
To restate the problem, a user may open a .htm, make some changes, and save
it. Of course, the field names generate a spell or grammar check, which end
up also saved with the .htm. Then when they print the .htm, the merge
process cannot locate the merge fields because of these control characters
automatically entered by Word spell/grammar check.
Does anyone have any ideas on what I might do to overcome this problem.
Many, many thanks for any and all ideas on this,
Mark Tag: Font of toolbar Tag: 112403
Listing procedures in Project
Hi, I have a template (xyz.dot) which contains over 100 UserForms and
Modules. I dread to think how many procedures are in them, but I need
to start documenting them.
Is there some code that can extract all the Subs and Functions within
the userforms and modules?
Thanks
Steve. Tag: Font of toolbar Tag: 112401
ASCII Dos Text
I have a file that is generated from our accounting program and is saved as
an ASCII Dos Text file.
I need to use vba coding that tells Word to open it as an ASCII Dos Text
file. There are two different special characters in the txt file which
separates the fields and ends the records. When Word opens the txt file,
those characters import as just squares with no way to distinguish between
the end fields and the end records.
Brenda Tag: Font of toolbar Tag: 112393
search only the words within a selection
Hi,
Does anybody know how to search for a certain word in a specific
selection/highlighted text/paragraph of a document only? I have tried
recording a macro but I was not able to get what I want. The following code
will highlight the paragraph/portion where the enclosing bookmark is located.
In that highlighted/selected area, the macro will search for the word
"hello". I only want the macro to find those which are only within the
selection. I know this is possible when using the Search & Replace Dialog box
but I can't make it run on macro. Below is my sample code.I can't figure out
what's missing. I am using Word 2003. Thanks.
Sub LinkTest()
Dim a As String
Selection.GoTo What:=wdGoToBookmark, Name:="tmp"
With Selection.Find
.text = "hello"
End With
Do
a = Selection.Find.Execute
If a = True Then
MsgBox (Selection.text)
End If
Loop While a = True
End Sub Tag: Font of toolbar Tag: 112384
.doc open as html
Hi all,
Is it possible,I save a word file as .doc but when open it,
it's open as html page.Is it possible with vba?.
.doc open as htm,and when close it,it returns to .doc
again.
Rgds,
Shiro Tag: Font of toolbar Tag: 112383
retrieve data back to userform
Hi,
I have a problem with bookmarks. I have a userform called "New application
form" made up for a template .dot. In the word, i have insert bookmarks that
correspond to the text fields in the userform. So, when user finishes filling
out the fields and hit "OK" button, all the data are put into bookmarks.
However, what i'm trying to do now is to be able to retrieve all those data
back from bookmarks to the form. I know the code to retrieve values from
bookmarks to textfields in the userform. The reason for this is to allow user
to edit some of the data through the form. (don't know if by doing this, i
have made my life more difficult). Anyway, i created another userform called
"Editing application form" and a Edit button (use macro). So when user clicks
on this button, it brings up the "Editing application form" with all the data
in their appropriate text fields.
The problem here is When user hits "Edit now" button, i got error message
saying
"The requested member of the collection doesn't exist". When i checked the
bookmarks, those bookmarks are not there. I believe this is because they are
not entered in the first place during the creation of the new application
form. (something new i learn again today)
so is there any other ways that i could use apart from bookmarks and still
helps resolve my issue?
Thank you in advance Tag: Font of toolbar Tag: 112380
Center text in current page
Hello:
I have generated a Word document from code with Visual Basic 2005. I'm using
Word 2003. I want to center a title in the first page (two lines), but only
in this page. I have tried a few method but they didn't work properly. Any
idea?
Thanks. Tag: Font of toolbar Tag: 112374
next page - section break / insert file
A 2 prong question:
I have a protected template which has 4 different check boxes. If a check
box is checked, I need to insert a section break/next page AFTER the page.
Once I have inserted the break, I then need to insert a file (document) from
our network drive.
This example, I could insert 4 different files to my template.
Not sure how to code appropriately to add the section break or to insert file.
Any help would be appreciated.
Thanks,
Bryan Tag: Font of toolbar Tag: 112355
page counting macro works one day, but not the next
In a previous post, I asked about methods for linking separate files into a
single document with a single TOC. I was directed away from using Master
documents, and towards using the {RD \f} feature.
This appears to work just fine. I insert the bracket(s), type in the file
name(s), generate the TOC. Of course each file starts page numbering at 1.
From this point, it was a short jump to using a macro created to count the
number of pages in a document and key off of that. I did not devlope this
macro but am using the one provided in the article
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=148
Here's my problem. It works great, at first. I open and close the main
document, happily add more documents, generate a new TOC, update the page
numbers, save, close, open, etc. Then I go home for the day. The next day,
when I try to run the macro (yes, I enabled macros upon opening the
document), having made no changes in any of the documents, the macro won't
run. It hangs up on the first document with the following:
Runtime error '5174'
file could not be found
check spelling, try different file name, etc
File names did not change from the previous day. Removing the first file
from the {RD} list doesn't solve the problem. The debugger doesn't help at
all, showing a stop at this line in the macro:
Set oDoc = Documents.Open(FileName:=strCode)
If I remove all the RD coding, and start over, it all works again, until the
next day, when the whole error cycle begins again.
Whats going on and how do I fix it? Tag: Font of toolbar Tag: 112354
Probleam with page numbering
Hi again all.
I have hit a bit of a wall here and need some help please.
I am writing a multi chapter manual. The layout of the document dictates
that the first chapter is Chapter 0 and it then continues normally from
there. That part is fine. Where I am running into problems is inserting the
chapter number then page number into the header. The TOC must have section
then page number (eg: 0-1......3-23 etc). The prog is not letting me change
the chapter # for the first chapter (in the header). It will not let me
select 0 but starts from 1. Is there any way to sort that out without having
to renumber the chapters to start with 1?
Thanks in advance.
Dominic Tag: Font of toolbar Tag: 112351
Path for utilities
We've added commands to our Word menus to let the writers open our (HTML)
style guide and the MW dictionary. I path the style guide to a location on
our LAN. The dictionary commands are created on installing the MW dictionary,
but I control the command and toolbar button locations in our menus and
toolbars.
Now I'm sending my global add-ins to remote offices. The remote writers
don't have access to our servers (or LAN) and they may have a different
dictionary installed.
I'm thinking it would be better to code my VBA to use a Word path, like
those available on Tools > Options > File Locations. Maybe
Options.DefaultFilePath(wdToolsPath). The users could arrange to put a copy
of the style guide in that path, and a shortcut or copy of the dictionary EXE
in that path.
What do you think? Is this a reasonable strategy? Is there a better path to
use?
Bear
--
Windows XP, Word 2000 Tag: Font of toolbar Tag: 112343
Vertical Scroll bar not operable in a Word form
Hi,
I have a simple User Form in Word that is sent to multiple users to collect
information. Due to the display resolution settings, some of the users are
able to see the form in its entirety they are unable to see the bottom
portion of the form.
I went to the form's property after opening the form in VBA mode and set the
"Scrollbars" property to "2 - frmscrollbarsvertical." This shows the
vertical scroll on the right side of the screen, but I am unable to use it
and move up and down on the form (there is no scroll drag in that scroll
screen). What am I doing wrong? / How can I correct this behavior? Thank
you for your time. Tag: Font of toolbar Tag: 112341
need code to get entire paragraph containing selected text
Working on an Excel macro that needs to get some info out of a Word doc.
Need a bit of code to open the doc, search for an occurrence of a text string
(will only occur once) then assign the entire record (paragraph) containing
that string to a string variable. The name of the file to be opened is
already known.
Thanks for any help. Tag: Font of toolbar Tag: 112338
Updating Multiple Documents in a Folder
I have several hundred Word documents in a network folder
(G:\Marketing\Updates) that I need to update with the same information. I've
created a procedure to do this to one document at a time, but I could save a
ton of time by having it automatically open each document in that folder, run
the procedure, save it, close it, then open the next one, etc.
Could someone help me with the code I need to do this? Thanks!
--
Steve C Tag: Font of toolbar Tag: 112334
Range and Tables
Hi. I use this:
Public AllTags As New Collection
Public AllPoss As New Collection
Set RegularExpressionObject = New RegExp
With RegularExpressionObject
.Pattern = "\[\[|\]\]|\["
.IgnoreCase = True
.Global = True
End With
Set Matches = RegularExpressionObject.Execute(doc.Range.Text)
For Each Match In Matches
AllTags.Add (Match.Value)
AllPoss.Add (Match.FirstIndex)
Next
In other function when I want to delete some range:
Dim rang As Range
Set rang = doc.Range
rang.SetRange AllPoss(k - 1), AllPoss(k)
rang.Delete
It is ok but if I have tables in word document the range is other.
Example: If original postion is 30, This code Match.FirstIndex return 32
when position 30 is in Table. If we have not table Match.FirstIndex return
30. If wi have table original postion is 30 but Match.FirstIndex return 32.
Pleace help me. How I can get original postion in table? Tag: Font of toolbar Tag: 112333
Why Close when you can Kill?
Hi
Can somebody please give me a good reason why Close function of certain
things like forms or word application obejcts should be used rather than just
killing them of as a process?
The thing is Im working with word objects and it is just such a pain because
when ever PC slows down you start getting errors like: Call was rejected by
callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))
But if you close (for example) word app with process killer it works just
fine (no questions, no problems etc... :))
--
Government sucks, but the beer is still good! Tag: Font of toolbar Tag: 112327
Error &H80004005
Using Windows XP, EXCEL Office 2003.
Each time I open an EXCEL workbook, I get the MICROSOFT VISUAL BASIC system
error '&H80004005 (-2147467259) unspecified error' message. I click on OK
about 17 times and then get another error message 'Compile error in hidden
module: This Workbook'. This happens each time I open an EXCEL file whether
it is a new one or not. Can anyone help me get rid of this, please?
Thanks
Yendorian Tag: Font of toolbar Tag: 112326
issue with filedialog browser
Hi,
I have a question. I've a userform that has a textfield. Next to it, there
is a button with caption "Browse". I was thinking that when user wants to
insert a picture, he/she clicks on "browse" that will bring up a filedialog
box for user to select which image file they want to insert to the document.
Once, they have chosen the file, the filepath will be captured and shown in
the textfield that is next to it. After user has filled out all the text
fields in the userform and press "ok" button, all the user data will be
dumped to the word document. I use bookmark to do this.
So, getting back to my question. i have a bookmark in the word document. I
was hoping, the image will be placed where the bookmark for the image is in
the word document.
I use the following code to bring up the filedialog but couldn't retrieve
the filepath to the textfield. Instead, it actually opens up the file.
Dialogs(wdDialogFileOpen).Show
I have tried to use the following codes
Dim dlgOpen As FileDialog
Set dlgOpen = Application.FileDialog( _
FileDialogType:=msoFileDialogOpen)
but got error message saying "invalid property".
I have done this before in excel but the codes below doesn't work well with
word.
filein = Application.GetOpenFilename()
Your help would be greatly appreciated.
Thank you in advance Tag: Font of toolbar Tag: 112318
[Help]How to adjust Embedded Excel sheet 's view range
the detail info, please follow this link:
http://msdn.microsoft.com/newsgroups/default.aspx?&query=bluecoast&lang=en&cr=US&guid=&sloc=en-us&dg=microsoft.public.excel.programming&p=1&tid=27a75cb0-49f5-4d0c-8072-ca7f4453558b
--
From China Tag: Font of toolbar Tag: 112316
issue with opening a file
Hi,
I have a question i need to ask of you MVP experts. Say, i have a several
customised templates dot files e.g. our company Letter template, Fax
template, and so on. Each of these templates have a userform (macro -
autonew) that would be called up as soon as a user opens up the template
My question is if i have a customised toolbar that has buttons for each of
these templates in the normal.dot. So when user opens up a word document,
he/she will find the toolbar. On the dropdown list, there are "Company
Letter", "Company Fax", "Company Report". When they click on Company Letter,
it brings up the Letter doc with the userform pops up waiting for user
inputs. That's the idea.
Today, i tried to do that but it actually opens up the template Letter.dot.
Hence, there is no userform showing up. This is not what i anticipated.
Here is my code for testing purpose only
Sub Macro1()
Documents.Open FileName:="C:\Documents and Settings\myComp\Application
Data\Microsoft\Templates\Company Letter.dot", ReadOnly:=True
End Sub
I might have used the wrong code here for opening a file.
Your ideas would be greatly appreciated.
Thank you in advance Tag: Font of toolbar Tag: 112310
Excel (VBA) 2007 workbook in 2003 - available resources??
I have created from scratch a new main workbook and several 'satellite'
dynamically populated/'built' report templates - in 2007 (as, 2003 to 2007
seemed to fraught with danger).
All runs well, I have saved versions of the 2007 workbooks as 97-2003
workbooks with a couple of compatability 'fixes' around colour formats and
shape formats. In 2003, I can run these (both the master workbook and the
report templates )independantly and all works fine.
But - if I call the report via the parameter selection main workbook
reporting FORM - the report is found, opened, parameters populated, list
boxes filled and report dynamically structured - all well. THe code then
seeks to return to the main workbook to wrap up there - - and, alas, XL
either falls over OR I get the following message (ad-infinitum):
"Excel cannot complete this task with available resources. Choose less data
or close other applications."
Note - if the report is already open - and NOT opened via the procedure -
then, all is fine again - however, that's not really sustainable - to open
all report templates first...but - even though there ARE not links, is there
some silly order of opening issue here?
----any ideas??
There ARE pictures and shapes and activeX combo boxes on the report template.
The main workbook has pictures, shapes (acting as buttons), forms galore.
I've already found that using a 'shape' in 2007 to close a workbook is
dangerous and use activeX controls for that. I'm just a tad nervous about
this whole 2003/2007 thing. Tag: Font of toolbar Tag: 112309
How to replace with a new template to a document
Here is my code:
Set thisDoc = Application.ActiveDocument
Set myTemp = thisDoc.AttachedTemplate
If myTemp.Path <> "C:\MyWordTemplate" Then
With thisDoc
.AttachedTemplate = "C:\MyWordTemplate\TestTemplate.dot"
.Save
End With
End If
I received the following message:
Word cannot attach a document to a protected template.
Thank you for any help. Tag: Font of toolbar Tag: 112301
normal.dot locked?
I'm using Word 2003. I have a document created, for which I created a macro
that I saved. It runs fine. When I try to go to Tools | Macros and select
the new macro and click Edit, it tells me "Project is Unviewable". If I go
to Tools | Macros | Visual Basic Editor and right-click on "Normal" and
select properties, it tells me the same thing.
Additional info - I had wanted to eliminate the warning I got about embedded
macros, so I used Digital Signing, creating my own digital signature using
"Digital Signature for VBA Projects". Note that with respect to Digital
Signing, VBA macros within word, I know just enough to get myself into
serious trouble, and not much more. Anyway, I suspect I've dug myself a
hole, and I'm trying to figure out how to get out. How do I fix my
Normal.dot, and how do I fix things up so I can go back and edit this macro
that I created? Any ideas? Tag: Font of toolbar Tag: 112300
Word 2007 ribbon
I am using the custom user interface editor to add a custom ribbon to a Word
2007 template. Is it possible to have the label on a button wrap to 2 lines?
I want it to look like this:
General
Instructions
NOT
General Instructions Tag: Font of toolbar Tag: 112299
Searching for words in word document
I am c programmer who needs help with an idea. I have a lot of programs and I
place them in a word document to add notes not relevent to coding. After I
save them how can I search the documents for a particular word quickly. Sort
of like find.. next. Any help is greatly appreciated. Thanks.
-Carl Tag: Font of toolbar Tag: 112298
ending multiple if/with statements
I have what I know has to be a very basic programming question. But I always
have trouble with this and have not been able to locate an answer that has
made it clear to me.
When you have multiple if and with statements: what is the proper sequence
to end them.
for example
if
with
with
if
I need to end the two "with" statements and the last "if", but not the first
one just yet. what is the proper sequence to end them?
end with
end with
end if
OR
end if
end with
end with
If someone could explain how to know what the sequence should be, I would
greatly appreaciate it. Thanks. Tag: Font of toolbar Tag: 112296
Inserting Checkboxes into a table as an InlineShape using VBA coed
I wish to insert two checkboxes, side by side on the same line, in the third
column of a three column table. The Caption for one checkbox should be
"YES" and the other one should be "NO". I can insert one checkbox, but when
the code runs for the second checkbox, the first box gets overwritten. How
do I place the second checkbox next to the first checkbox on the same line?
I also want a small space between the two, say three spaces. Here is my
code. Thank you.
Sub insertInlineShapesCheckbox()
Dim myCheckbox1, myCheckbox2
'shifts insertion point to first tab
Selection.TypeText Text:=vbTab
'insert first checkbox
Set myCheckbox1 = Selection.InlineShapes.AddOLEControl(ClassType:="Forms.
CheckBox.1")
With myCheckbox1.OLEFormat.Object
.TextAlign = 3
.Alignment = 0
.Width = 43
.Caption = "YES"
.FontName = "Arial"
.FontSize = 11
End With
'Selection.TypeText Text:=" "
'Selection.TypeText Text:=vbTab
'insert second checkbox
Set myCheckbox2 = Selection.InlineShapes.AddOLEControl(ClassType:="Forms.
CheckBox.1")
With myCheckbox2.OLEFormat.Object
.TextAlign = 3
.Alignment = 0
.Width = 43
.Caption = "NO"
.FontName = "Arial"
.FontSize = 11
End With
End Sub
url:http://www.ureader.com/gp/1022-1.aspx Tag: Font of toolbar Tag: 112291
Can't read Range.Text in a protected document
I need to find all emails inside a Word document. The problem is that when
the document is protected, I can't read the Text property of the range. I get
an error saying that the document is protected (Error #4605). All I'm doing
is reading, I'm not modifying anything. I use the Split function to get the
sentence of words where the @ sign was found, then I loop through the
elements of my array until I get to the one that has the @ sign. It's this
line that causes the error.
Here part of my code:
For Each rngStory In objDocument.StoryRanges
With rngStory.Find
.ClearFormatting
.Text = "@"
.Wrap = wdFindStop
.Forward = True
End With
Do Until rngStory.Find.Execute = False
With rngStory.Duplicate
.Expand Unit:=wdSentence
myArray = Split(.Text, " ", -1, vbTextCompare) '///
Error here !!!
If UBound(myArray) <> -1 Then
For i = 0 To UBound(myArray)
If InStr(1, myArray(i), "@", vbTextCompare) <> 0
Then
'/// ... Process Email here
numEmailsFound = numEmailsFound + 1
End If
Next i
End If
End With
Loop
Next rngStory Tag: Font of toolbar Tag: 112289
Search within a range
I have defined a range. Now I need to be able to search for a specific
phrase, move to the end of that phrase, insert a carriage return and insert a
new phrase. This is what I was trying, but it is not working. I don't get
any errors. It just doesn't work. I'm pretty sure it has something to do
with meNotice vs. selection. But I just can't quite figure out the syntax.
Any help would be greatly appreciated.
Set meNotice = .Sections(.Sections.Count).Range
With meNotice.Find
.Text = "time shown below."
If .Execute Then
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.InsertAfter Chr$(13) & "PLEASE TELEPHONE ME IMMEDIATELY."
End If
End With Tag: Font of toolbar Tag: 112288
turn off automatic date completion
When I write a word in my Microsoft words 2007 editor that indicates the
beginning of date some automatic completion mechanism is triggered displaying
the full date.
Unfortunately in my native language (Swedish) there are some words that are
very common but that also could be the beginning of a date so this flashing
occurs very often.
I do not like this so I wonder how a script could look to disable this
mechanism? Tag: Font of toolbar Tag: 112287
Make a copy of a Word VBA programme saved in the template directory
Hi,
I have written a complicated Word VBA programme and saved it as a
template. May I ask how I can make a copy of it so that I can move
the copy to another computer and use it there? Thanks.
Mike Tag: Font of toolbar Tag: 112285
Spellchecking a Protected Document
This seems to be a popular topic lately, so I thought I'd chime in as well.
While the article at
http://word.mvps.org/faqs/macrosvba/SpellcheckProtectDoc.htm is great if you
want to check the spelling of the information input into formfields, my
problem is a bit different. I have (Word 2003) templates that produce
forms-protected documents, but the documents themselves don't contain any
formfields. I use forms protection only because it allows me to protect only
certain sections of the document, such as the header and footer, while
leaving other sections, such as the main body of the document unprotected.
The spellchecker checks the spelling in the unprotected sections OK, and I
don't really mind if it doesn't check the spelling in the protected sections
because 1) I know that I haven't made any spelling errors in the
'boilerplate' in these sections; and 2) if the user has made a spelling error
in the 'variable' information, they can just rerun the code in template to
correct the errors. However, there is a deficiency in the native spellchecker
that I've been asked to develop a workaround for.
In an unprotected document, if none of the choices in the 'Suggestions' list
are viable, you can just type in the 'Not in Dictionary' box to make the
change. However, this doesn't work in a protected document; the text in the
'Not in Dictionary' box is treated like it's in a protected section. I could
always write code that unprotects the document before displaying the
spellchecker, but there are a couple of drawbacks:
First, this will allow the users to spellcheck the protected sections as
well, which is not really a major problem except that if the user corrects an
error that was introduced through the input of the 'variable' information
described above, this correction won't get replicated back into the data from
the UserForm. Thus if the user reruns the template, the correction won't be
there and the error could be reintroduced without the user realising it.
However, I can live with this.
The real problem is that the spellchecker dialog isn't modal to Word.
Therefore, if I unprotect the document, the user now has full access to the
whole document, _including_ the protected sections. And believe me, the users
will take advantage of this whenever possible; I learned this when I told the
users I was going to fix a bug in my code that left the document unprotected
and got a... umm... less than favourable response. ;-D
Does anyone know a way to enable the editing capability in the 'Not in
Dictionary' box without unprotecting the document? Or will my users just have
to live with this limitation? (The second choice is acceptable as I'm quite
happy to tell the users 'No' - as long as I can justify the response.)
--
Cheers!
The Kiwi Koder
Please note: Uninvited email contact will be marked as SPAM and ignored -
unless you want to hire me. Tag: Font of toolbar Tag: 112277
Sharing Arrays Between Modules
In an earlier post, Jean-Guy Marcil provided me with some excellent
instruction on structuring projects to separate UserForm-related processes
from document-related processes. (Thanks again, Jean-Guy!) I'm now trying to
apply this structure to a somewhat more complex project and have run into a
problem straight away.
In this new project, I use arrays to collect sets of similar information
(e.g. the names and addresses of multiple parties to a contract). These
arrays all reside in the UserForm class module, since they are obviously
integral to the processes related to the UserForm; i.e. UserForm operations
are used to create and maintain the arrays, and the arrays are used to
display information in the UserForm.
However, I cannot find a way to take the information in these arrays and
transfer it back into the 'operational' class module that is used to perform
the actual document-creation processes. UserForm controls (and the values
contained therein) are simple enough to access and variables can be declared
as Public and then just become a 'pseudo-attribute' of the UserForm object,
but arrays cannot be Public.
For obvious reasons, I don't want to dynamically create a heap of Public
variables to dump the contents of the arrays into and then rebuild the arrays
on the 'operational' side, and doing something like grabbing the contents of
the ListBoxes that are used to display and maintain the arrays on the
UserForm and then attempting to parse this information scares the daylights
out of me. Does anybody have any suggestions on how to share contents of an
array between two modules?
--
Cheers!
The Kiwi Koder
Please note: Uninvited email contact will be marked as SPAM and ignored -
unless you want to hire me. ;-) Tag: Font of toolbar Tag: 112273
Help with MVP spellcheck protected form code
I am trying to use the code from
http://word.mvps.org/faqs/macrosvba/SpellcheckProtectDoc.htm
and I got an error that the password was incorrect so I tried to follow the
directions from the website but I am still unsure where to insert
oDoc.Unprotect Password:="colleen"
And:
oDoc.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, _
Password:="colleen"
in to the code in the right places to get it to work. Help anybody? Thanks!
~Roxy Tag: Font of toolbar Tag: 112271
Fetching data in Excel from Word
Hello,
I have a Word document.
I have in an Excel file with thousands of IP adresses and other similar type
of information.
In the word document, I have to create a chapter for each physical servers
(a lot).
In each chapter, a table display the IP configuration of the sever as well
as virtualized servers inside it (a lot more)
These information are randomy defined in the Excel file.
What is the best way to do that ?
I'd like to have a button in the word document which call a macro.
This macro would open the Excel document and lookup the IP information based
on the server name.
Then, it would update tags or fields or variables that I would insert here
and there in the word document.
The goal here is to avoid regrouping & copying by hand thousands of IP
adresses, which is prone to mistakes.
Moreover, whenever the IP adresses are updated in the Excel file, I would
run the macro to update the word document.
Any good idea ?
I know how to do a macro in Excel, but never did one in word.
My main problem is how to create a "field" or a "variable" in the text
(generally in -but not restricted to- a table) that my macro would recognise
in the word document and update it ?
Thanks in advance.
JD Tag: Font of toolbar Tag: 112266
project locked
Hi,
Sorry if this has been asked recently or frequently.
Somehow all my projects are looked. If I download a dot-file, add it
and then try to open the macros in the editor, they are all locked.
Even if I myself create a dot-file, add a project, type some dummy
macrotext, close and then add that dot-file to another document, also
that project is locked. I can´t even open the properties.
The security settings are on the lowest level. Word 2003
What do I do wrong?
TIA
Örjan Tag: Font of toolbar Tag: 112265
Passing Values to a Module
I created a form in VB called DemogInfoForm and would like to know how I can
pass the value entered from a text box to a module? The instructions are on
the "command OK" button. The value will also be used to gather other
information from the mainframe. Here is what I got so far...
Sub OkButton_Click()
On Error GoTo Err_Command
Me.CaSEText.SetFocus
If Len(Me.CaSEText.Text) <> 10 Then 'Message that wrong number
of digits entered for case number MsgBox "Please enter the 10-digit Case
Number." _ & vbCrLf _ & " Please try again!", vbCritical, "10-digit Number
Error Message"
Exit Sub
Else
'Once the value is verified, I would like to pass the value to the
CaseNUMFind module .... thank you
CaseNUMFind (Number) 'Go to module Tag: Font of toolbar Tag: 112264
Word 2003 custom Menus change and disappear
Does anyone have a fool proof method for stabilizing custom menus (on the
menu bar) in Word?
I have a menu in a global template that should always show, as well as
document templates that each contain a menu I want to appear only when
someone is in a document created from that template.
The problem SEEMS to stem from OTHER people's software -- the menus will be
there but then they disappear, or multiple copies appear or the menu is
suddenly empty or has the name for one menu with choices for another menu on
it.
Note: Custom TOOLBARS seem stable, it is just the MENU that is problematic.
I have been fighting this for years and have done a lot of research but so
far everything I try has a hiccup at some point. The programming is all VBA
in Word .dot templates.
So far I have tried:
- Using tools, customize to create the menus w/in the appropriate templates
-- works great on my computer, but menus disappear/duplicate constantly on
about 80% of my clients.
- Programmatically creating the menus -- this is good for the global
template menu -- at first -- but somewhere through the day it gets trashed.
I can't get the template specific menus to behave. They constantly disappear.
- Write an event handler to delete and then recreate all menus and display
as (Tried with the "Document change" or "WIndow Activate" event for the Word
application) -- this seemed to work at first but suddenly the problems
returned. I did not want to just "show" the menus per the event handler
because they would suddenly have the wrong buttons or be empty part way
through the day. (Maybe I am not writing it right.)
Has anyone else had this struggle? It happens to me so much I am surprised
I can't find more postings about it. PLEASE HELP!!!!! Thanks so much. Tag: Font of toolbar Tag: 112256
OrganizerCopy Error Dialog Problem
When using OrganizerCopy, if the style name is not found in the source
document, Word returns an error dialog. In a VBA application, is there anyway
to suppress this dialog and let the code continue without the user having to
click OK?
The sample code. The dialog after the gSourceWordApp.OrganizerCopy call but
before the If Err.Number = 4198 Then line.
On Error Resume Next
Dim styleName As String
styleName = "corporateNameStyle"
gSourceWordApp.OrganizerCopy Source:=sourceDocument.FindInFileName, _
Destination:=indexWordDocument.FullName, _
Name:=styleName, _
object:=wdOrganizerObjectStyles
If Err.Number = 4198 Then
gSourceWordApp.OrganizerCopy Source:=sourceDocument.FindInFileName, _
Destination:=indexWordDocument.FullName, _
Name:="Normal", _
object:=wdOrganizerObjectStyles
End If Tag: Font of toolbar Tag: 112253
Comparing Word documents
I inherited some Word VBA code to format a report based on rtf output
from DOORS. I made some changes to the VBA to improve performance (it
used to run for more than hour) and now I would like to compare the
Word document produced from the latest version with a Word document
produced from the previous version of the Word VBA macros.
I am running Microsoft Office Word 2003. I opened the more recent
copy, and then:
1. pulled down Tools-->Compare and Merge documents...
2. checked the "Legal Blackline" checkbox
3. selected the baseline word document produced under the old macro
set
4. clicked on "Compare"
The only differences that showed up was that every row of the main
table is black-barred with (on each page) a change box pointing at the
header saying "Formatted Table".
When I move my mouse over the "Formatted Table" change box it says
"Author formatted Table:"
Any clue what this is trying to tell me? The contents look fine
otherwise.
--Thank you,
--Mike Jr. Tag: Font of toolbar Tag: 112251
Spaces after 1 incorporate footnote
Below is my 1 space after macro, but I need to add 1 space after footnote -
I keep getting errors in my attempts:
.^f<space><space>
to be .^f<space>
a single space after footnote is that possible to do?
Sub Spaces_After()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([.\?\!]) {1,}"
.Replacement.Text = "\1 "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " ^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWholeWord = False
.MatchWildcards = False
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.HomeKey Unit:=wdStory
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute
Wend
Selection.Find.Text = " ^l"
Selection.Find.Replacement.Text = "^l"
Selection.Find.Execute
While Selection.Find.Found
Selection.HomeKey Unit:=wdStory
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute
Wend
End Sub Tag: Font of toolbar Tag: 112250
VBA Code cleaners
Does anyone know where I can get a VBA Code Cleaner program which
works with Word 2003 and above, please?
All the ones I've found seem to concentrate on Excel but not Word.
I've always used the one mentioned in the MVPS site but this only
works up to Word 2002.
Thanks
Roderick Tag: Font of toolbar Tag: 112249
Changing the default spelling language for Word 2007
Hello,
Is it possible to change the default office (word) spelling language from
code?
Preferably from c#,
I have not found the location where word stores this.
Kind regards,
Sven Maes Tag: Font of toolbar Tag: 112240
if bookmark.Exist (Left("nut", 3)
Hi all
I am hoping to use VBA to check if a document has a bookmark starting with a
particular string. I thought I could use LEFT to check if it exists but it
does not pick up the bookmark.
Checking if bookmark exits works perfectly when not using LEFT
Ive tried:
If ActiveDocument.Bookmarks.Exists(Left("_BD", 3)) = True Then
msgbox "Yes its here"
end if
I found that looping through the document works but I do want to search for
each bookmark eg:
Dim myBM As Bookmark
For Each myBM In ActiveDocument.Bookmarks
If ActiveDocument.Bookmarks.Exists(myBM.Name) And Left(myBM.Name, 3) =
"_BD" then
do this
End If
Next myBM
Any ideas?
Thanks in advance Tag: Font of toolbar Tag: 112237
MACRO TO TOGGLE FONT ON AND OFF
I have document that uses a particular font (usually no more than a few
characters in length) in numerous places throughout. Is there a macro that
would toggle this font on and off using a shortcut-key combination (e.g.
like the way that CTRL + "I" does for italic type)?
--
JBusby Tag: Font of toolbar Tag: 112236
Wrong font color for envelopes
When I try to use the tab for letters and labels when printing an envelope,
the type comes out green even though black is the default color. It does not
happen with labels. Tag: Font of toolbar Tag: 112234
Programing the page number
Hello:
I have an application of Visual Basic 2005. I can make a word XP document
("Document 1") by code inside the application. I want to put the page number
in the document but I don't know how from inside the code of Visual Basic.
That's the problem.
Thanks Tag: Font of toolbar Tag: 112231
Is there a way to change the font on a toolbar item?