Problem creating Attribute on XMLNode
Hi,
I'm trying to write some C# code that automates Word to do the following:
- Open a document
- Attach my custom schema
- Search the document for some specific text
- When I find the text, create an XML Node that includes an attribute
- Save the document in XML format
First off, I'm a total rookie at this. But here's a bit of the code I wrote:
private void button1_Click(object sender, System.EventArgs e)
{
object sTokenPattern = "\\<%[A-Za-z.0-9]@%\\>";
object sReplace = "";
object wrap = Word.WdFindWrap.wdFindStop;
Word.WdSeekView[] locations =
{
Word.WdSeekView.wdSeekCurrentPageHeader,
Word.WdSeekView.wdSeekCurrentPageFooter,
Word.WdSeekView.wdSeekMainDocument
};
wordApp.ActiveWindow.View.Type = Word.WdViewType.wdPrintView;
for (int x=0; x < locations.Length; x++)
{
wordApp.ActiveWindow.ActivePane.View.SeekView = locations[x];
bool bFound = true;
while (bFound)
{
bFound = wordApp.Selection.Find.Execute(
ref sTokenPattern, // FindText
ref bFalse, // MatchCase
ref bFalse, // MatchWholeWord
ref bTrue, // MatchWildcards
ref bFalse, // MatchSoundsLike
ref bFalse, // MatchAllWordForms
ref bTrue, // Forward
ref wrap, // Wrap
ref bFalse, // Format
ref sReplace, // ReplaceWith
ref none, // Replace
ref bFalse, // MatchKashida
ref bFalse, // MatchDiacritics
ref bFalse, // MatchAlefHamza
ref bTrue); // MatchControl
if (bFound)
{
String sValue = wordApp.Selection.Text;
object ch = Word.WdUnits.wdCharacter;
object one = 1;
object range = wordApp.Selection.Range;
Word.XMLNode tokenNode =
wordApp.ActiveDocument.XMLNodes.Add("Token", (string)FCINS, ref range);
Word.XMLNode nameAttr =
tokenNode.Attributes.Add("tokenName", "", ref missing);
nameAttr.NodeValue = sValue;
wordApp.Selection.MoveRight(ref ch, ref one, ref
bFalse);
}
}
}
Now here's my problem. When the location is the main document, everything
works fine. But when the location is either the header or the footer, I end
up losing my attribute. That is, the code seems to execute just fine, but
after saving the document and inspecting the XML, only the nodes that were
created in the main document have their attributes. Here's some sample...
main doc -
<ns0:Token name="<%Common.DisplayName%>">
<w:r>
<w:t><%Common.DisplayName%></w:t>
</w:r>
</ns0:Token>
header -
<ns0:Token> <== NOTICE MY NAME ATTRIBUTE IS MISSING
<w:r>
<w:t><%CurrentUser.Name%></w:t>
</w:r>
</ns0:Token>
Am I way off base here? Any advice would be greatly appreciated.
-Rob Tag: Need to find the web wizzard in office Tag: 66371
Insert shape at x, y on page n
I want to insert the shape on the last page of a document (whatever page #
that may be, it's variable). It's a textbox with some text in it, and it's
background is filled with a bitmap of someone's signature - it goes on the
last page in the bottom-right corner to "sign" a document. Our users "apply
a signature to the document" by clicking a little macro button that does
[essentially] this:
Dim objYouWereHere as Range
Set objYouWereHere = Selection.Range
Application.ScreenUpdating = False
'Physically move to the "last page"
Selection.EndKey Unit:=wdStory
'Position the signature textbox
With ActiveDocument.Shapes("SignatureBox")
.Top = 536
.Left = 231
End With
'Return my user to wherever they were prior to running the macro
objYouWereHere.Select
Application.ScreenUpdating = True
I'm not well versed enough in word/vba to know the answer to this; but is it
possible to programatically define the last page (maybe as a range?) in such
a way that I could insert a shape onto it at an x, y coordinate relative to
that page **without** having to move the selection? With the above
methodology, the user does end up at wherever they were prior to running the
macro, but the objYouWereHere.Select call can sometimes leave them at a new
vertical scroll position and it's a little disorienting for them.
So, before I go hunting down how to store & retreive the vertical scroll
position (similar to how I store and retrieve the selection pre & post
textbox adjustment)... is there a more "elegant" way to do this that doesn't
require I move the selection at all? Insert shape at x, y on page n,
without involving the Selection? Tag: Need to find the web wizzard in office Tag: 66370
Command Button and Lock
I need information on how to add a CommandButton to Word2000 and have it be
able to email that form back to the client with a set email address. I
would also need to lock that form also. It does not allow me to lock the
word document if I put in a CommandButton.
--
Message posted via http://www.officekb.com Tag: Need to find the web wizzard in office Tag: 66369
Copy formfield value from one file to another
I have two template files. The first one uses userforms to fill out fields in
the template. Once this form is filled out, another template is opened
(depending on user input). This second template also has userforms. The two
documents have four fields in common. How can I get the values of these
fields on the second form without the user having to enter them again? Tag: Need to find the web wizzard in office Tag: 66366
Picture opening as a doc??????????????
I don't even know how to search on this one! I'm quite confused. Following
is a code snippit. It has opened a template and updated some doc variables
and name then saves it. The template contains a picture. When I insert the
"oDoc.SaveAs strDocName"... word opens up to a window for editing the picture
(on top), and a window for the new doc. Prior to adding the save, only one
window would open and it was for the new doc. HELP!! Thanks!
With oApp
.Options.DefaultFilePath(wdDocumentsPath) = ROOT_PATH & strSavDir
.Selection.Goto wdGoToBookmark, Name:="WrittenBy"
.Selection.Text = Author
.Selection.Goto wdGoToBookmark, Name:="StartHere"
oDoc.SaveAs strDocName
.Visible = True
End With Tag: Need to find the web wizzard in office Tag: 66363
form fields show up in RTF format
I hope someone has a clue on this one!
I created a form with a VBA macro that automatically does a SaveAs action to
ensure the file is stored using field content to ensure the right file
naming convention. I made it save in RTF format because that way the new
document no longer contains my homemade macro which is needed to be able to
e-mail the documents created this way since firewalls do not like homemade
macros.
Now, to my surprise the RTF files created this way still contain the drop
down option lists from the original form ( I had expected only flat text to
come through when saving as RTF)
Does anyone have a clue why this happens or even better, how to prevent it?
TX
Saskia Tag: Need to find the web wizzard in office Tag: 66360
Column Break Help
I am trying to create a word document using VB6 and need to use columns
breaks but cant seem to find out why my code doesnt work the way it
should. It creates a column break but when i trying to go back to one
column to finish off the document it takes the second column and puts
it on the next page. Any ideas on what i may be doing wrong with the
code below?
With surveyApp.Selection
surveyApp.ActiveDocument.Range=AD=AD=AD=AD(Start:=3D.Start,
End:=3D.Start).InsertBreak
Type:=3DwdSectionBreakContinuous
.Start =3D .Start + 1
With surveyApp.ActiveDocument.Range=AD=AD=AD=AD(Start:=3D.Start,
End:=3DsurveyApp.ActiveDocument.=AD=AD=AD=ADContent.End).PageSetup.Text=ADC=
=ADo=ADl=ADumns
.SetCount numcolumns:=3D2
.EvenlySpaced =3D True
.LineBetween =3D False
.Width =3D InchesToPoints(2.75)
.Spacing =3D InchesToPoints(0.5)
End With
Dim rs3 As New ADODB.Recordset
Dim rs4 As New ADODB.Recordset
Dim cmd As New ADODB.Command
cmd.ActiveConnection =3D conn
rs3.Open "SELECT * FROM groupname", conn, adOpenDynamic,
adLockOptimistic
If rs3.EOF Then
.TypeText Text:=3D"None indicated"
.TypeParagraph
.TypeParagraph
rs3.Close
Else
'Setup for mutliple columns
Dim currentline As Integer
Dim group(500) As Integer 'this is the line that the group starts
on
Dim currentgroup As Integer
Dim lines(500) As Integer 'this is the current group for a given
line
currentline =3D 0
currentgroup =3D 0
While Not rs3.EOF
currentgroup =3D currentgroup + 1
group(currentgroup) =3D currentline
lines(currentline) =3D currentgroup
.TypeText Text:=3Drs3("groupname")
.TypeText vbTab
.TypeText Text:=3Drs3("problem")
.TypeParagraph
currentline =3D currentline + 1
rs4.Open "SELECT * From problemoccurred WHERE groupname =3D '" &
rs3!GroupName & "' order by problemoccurred desc", conn, adOpenDynamic,
adLockOptimistic
While Not rs4.EOF
.TypeText Text:=3Drs4("problemdesc")
lines(currentline) =3D currentgroup
.TypeText vbTab
.TypeText Text:=3Drs4("problemoccurred")
.TypeParagraph
currentline =3D currentline + 1
' .MoveRight unit:=3DwdCell
' .MoveRight unit:=3DwdCell
rs4.MoveNext
Wend
rs4.Close
rs3.MoveNext
Wend
rs3.Close
If currentgroup > 1 Then
Dim gobackto As Integer
If lines(currentline / 2) =3D 1 Then
gobackto =3D group(2)
Else
gobackto =3D group(lines(currentline / 2))
End If
.MoveUp unit:=3DwdLine, Count:=3D(currentline - gobackto)
.InsertBreak wdColumnBreak
End If
.EndKey wdStory
With surveyApp.ActiveDocument.Range=AD=AD=AD=AD(Start:=3D.Start,
End:=3D.End).PageSetup.TextColum=AD=AD=AD=ADns
.SetCount numcolumns:=3D1
.EvenlySpaced =3D True
.LineBetween =3D False=20
End With=20
End If=20
End With Tag: Need to find the web wizzard in office Tag: 66352
Find and replace font specs with macro
First, my apologies on two counts: one, that I'm sure this is really basic,
and two, that I think I may have asked this before but can't find and/or
recall the answer.
All I'm trying to do is to create a macro that will find a given string of
text and change it to bold and underline (single).
Thanks in advance! Tag: Need to find the web wizzard in office Tag: 66340
Adding a button to Automaticaly E-mail a Word Document?
Hi there,
im want to make a word document with fields for users to fill out, then
press a button at the bottom, and the document will email to a specified
email address' (within the programming) and then close the document. - the
document will be opened from an email.
if anyone can tell me how to achieve this, that would be great,
thanks,
Neil Tag: Need to find the web wizzard in office Tag: 66338
Problem with GoToNext(what:=wdGoToSpellingError)
I am using Word 2003 for this problem. I have not tried with earlier
versions.
Using the code below, where rngError is of type Word.Range, strError is of
type string and lngLastStart is of type Long, I find that the GoToNext fails
when there is punctuation (e.g., comma, period, or slash) immediately after
the spelling error.
In that case, one of two things happens:
1. If the spelling error is the first word in the document, that spelling
error is found, but no others are found.
2. If the spelling error is not the first word in the document, then all
spelling errors up to, but not including that error, are found, and no
errors after that spelling error are found.
I did not find anything in the MSFT KB on this issue.
The same problem occurs if I use GoToNext with the Range object, instead of
the Selection object.
The problem does not occur using the ProofReadingErrors collection, only
when navigating with GoToNext(what:=wdGoToSpellingError).
Any ideas on a workaround, without using the ProofReadingErrors collection?
lngLastStart = -1
Do
Set rngError = Selection.GoToNext(what:=wdGoToSpellingError)
With rngError
If .Start = lngLastStart Then
Exit Do
End If
strError = .Text
lngLastStart = .Start
.Collapse direction:=wdCollapseEnd
.Select
End With
Loop Tag: Need to find the web wizzard in office Tag: 66333
word pagination
I don't know if I am posting this to the best place, so if I not please
suggest a better one.
We currently have word and excel templates that are used to generate
documents that are pasted into scientific notebooks. The auditors put page
numbers on these pages by using a manual stamp. We have to do this to insure
that noone can come along and create another page 12. I would like a way to
automate this somehow.
Can I create a template that when printed can pull a page number from a db
then print that word doc and never print that same number again. I know
there are always ways someone can beat the system but what's my best
approach??
Thanks for reading and thanks for any susggestions.
Mike Tag: Need to find the web wizzard in office Tag: 66328
DB connectivity in word
How can I make database connectivity (Access and Excel) in Microsoft Word
VBE. If possible please give me one sample code. Tag: Need to find the web wizzard in office Tag: 66323
Tables--Reading them Quickly
I have a pretty fast machine (everything else I do goes at 'lightning
speed'). Yet it takes almost 20 seconds for my computer to read the 300
row/2 column table. Am I doing something inefficient with this formula?
-------snip-------------
Set otable = Selection.Tables(1)
NumRows=otable.Rows.count ' this ranges from 300 to 350
redim Name1(NumRows)
redim Name2(NumRows)
With otable
For nRow = 1 To NumRows
Name1(nRow) = .Cell(nRow, 1)
Name2(nRow) = .Cell(nRow, 2)
Next
End With
------snip--------------
What improvements are possible? Are reads from tables just inherently slow?
Thanks.
-- Ed Tag: Need to find the web wizzard in office Tag: 66322
Making an available printer Active
Hello all, I'm not quite a novice but...
I've seen the article on word.mvps.org about getting a list of all the
available printers and can get it into a ListBox without any problem.
But how do I get one of the printers from the list to be the ActivePrinter ?
I want a basic form without offering any chance to change print parameters -
just the a.m. ListBox and a button that says "Print" and will hide the form
when finished. Tag: Need to find the web wizzard in office Tag: 66320
Run a macro automatically when opening a document - how?
I'm a novice with macros and want to be able to run a macro automatically
when opening a document to execute a bunch of ASK and REF fields to capture
setup info e.g. customer name, address etc, store them in bookmarks and then
paste the data into various parts of the doc.
Is a macro the best way to do this or is there a better way? Tag: Need to find the web wizzard in office Tag: 66319
Attached template : orginal name
Hi,
I use vba to change the "attached template" value of copied documents to a
new value. However, Word changes the value to "normal.dot" if it doesn't
find the template, but it stores the original value somewhere, cause you can
see it in the document, how can I find this original value through vba ?
thanks in advance
Xavier Tag: Need to find the web wizzard in office Tag: 66313
word doc with fillin fields opens with no toolbars
Hi,
I'm using vba to open word documents using templates.
I've got a problem where if I open a document using a template that
contains fillin fields, the document opens (after the user has entered
values into the fillin fields), but with no toolbars - not even the
Menu toolbar.
However, if I open a document using a template that doesn't have the
fillin fields, the document opens and the toolbars are there.
If I manually open a document using the template containing fillin
fields, I don't get the missing toolbars problem.
The vba code I have to open the document is:
-------
Dim WordObj As Word.Application
Set WordObj = CreateObject("Word.Application")
Dim objWord As Word.Document
Dim strFile As String
strFile = "C:\Program Files\Microsoft
Office\Templates\NotificationTemplate.dot"
Set objWord = WordObj.Documents.Add(strFile)
WordObj.Visible = True
WordObj.Activate
--------
Can anyone help?
Thanks,
t. Tag: Need to find the web wizzard in office Tag: 66310
syntactical help
I'm trying to use the following method to insert a textbox into a document
and format it as I go, but I'm up against some sort of vba
compiler/syntactical problem I don't understand yet:
With ActiveDocument.Shapes.AddTextBox([orientation, position size etc])
...[various textbox class members here, e.g....]
.TextAlign = fmTextAlignCenter
.BorderStyle = fmBorderStyleNone
[etc]
End Width
But Option Explicit doesn't like that, presumeably becuase 'AddTextBox' is
returning a Shape, not a Textbox.
My first instict is to want to do something like...
With Ctype(ActiveDocument.Shapes.AddTextBox(...), TextBox)
...[compiler-friendly textbox member references]
End With
But that's vb.net, not vba. How do I get vba to let me play with what
.AddTextBox is returning as if it were a textbox while keeping Option
Explicit happy? I don't want to cheat and turn it off. Is there a
Ctype-like keyword, a different add-a-textbox method I'm not aware of? Tag: Need to find the web wizzard in office Tag: 66306
insert multiple documents into document retaining headers and foot
question:
I know how to insert multiple documents and an example is also in the list
below.
Only problem is that when using this method headers and footers are not
retained.
this is caused by the sameasprevious when inserting a sectionbreaknextpage
at the end of of each document.
This means that when I insert for example the second document the header and
footer of the first are being used for the second document.
This is the code from steve lang, only thing adapted is the pagebreak that
is now a sectionbreak, this is needed to keep pagesettings correct:
Sub Foo()
Dim i As Long
Application.ScreenUpdating = False
Documents.Add
With Application.FileSearch
'Search in foldername
.LookIn = "C:\test"
.SearchSubFolders = False
.FileName = "*.doc"
.Execute
For i = 1 To .FoundFiles.Count
If InStr(.FoundFiles(i), "~") = 0 Then
Selection.InsertFile FileName:=(.FoundFiles(i)), _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.InsertBreak Type:=wdsectionBreaknextpage
End If
Next i
End With
End Sub
turning off sameasprevious after inserting the doesn't help very much
because at that point the header and footer of the first document are already
used.
Maybe there is a way, that I don't know to bring them back into the previous
state
If been trying all kinds of stuff to get this to work, nothing seems to work
only thing that did work was using a maindocuments and add subdocuments to
it but this was way to slow when you need to append for example 1000
documents.
Please help me on this issue,
--
Rocco Tag: Need to find the web wizzard in office Tag: 66302
Find routine in VBA
I want to use VBA to find all the bold text in a document. When found and
still selected, copy the formatting, apply a character style called WHATEVER,
then paste the copy formatting back on top of the same text. Once that is
done, Find the next occurance. I need to do this for Italic, and Underline,
and Plain Text.
I can't use wdReplaceALL because I need the text still selected so I can
apply the character style. I can't seem to get this to work. The macro runs
forever. When I break, all the bolded text is exactly what I want (the
character style + bold) but nothing else. One time I got all but the
italics.
Dim doc As Document
Dim strFilename As String
Dim styFilename As Style
Dim rngToSearch As Range
Dim rngResult As Range
Dim f As Font
Set doc = ActiveDocument
'Capture the document name into a variable
strFilename = Left(doc.Name, Len(doc.Name) - 4)
On Error GoTo ErrorHandler
'Define a character style with no font attributes
Set styFilename = doc.Styles.Add(Name:=strFilename,
Type:=wdStyleTypeCharacter)
With styFilename
With .Font
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
End With
End With
BeginHere:
Set rngToSearch = doc.Range
Set rngResult = rngToSearch.Duplicate
'Make sure there isn't any text currently selected
If Selection.Type <> wdSelectionIP Then
Selection.Collapse _
Direction:=wdCollapseStart
End If
'Look for Bold text
Do
With rngResult.Find
.ClearFormatting
.Format = True
.Font.Bold = True
.Forward = True
.Wrap = wdFindStop
.Execute
End With
If Not rngResult.Find.Found Then Exit Do
Set f = rngResult.Font.Duplicate
With rngResult
.Font.Reset
.Style = styFilename
.Font = f
.MoveStart wdParagraph
.End = rngToSearch.End
End With
Set f = Nothing
Loop Until Not rngResult.Find.Found
'Look for Italic text
Do
With rngResult.Find
.ClearFormatting
.Format = True
.Font.Italic = True
.Forward = True
.Wrap = wdFindStop
.Execute
End With
If Not rngResult.Find.Found Then Exit Do
Set f = rngResult.Font.Duplicate
With rngResult
.Font.Reset
.Style = styFilename
.Font = f
.MoveStart wdParagraph
.End = rngToSearch.End
End With
Set f = Nothing
Loop Until Not rngResult.Find.Found
'Look for underline text
Do
With rngResult.Find
.ClearFormatting
.Format = True
.Font.Underline = wdUnderlineSingle
.Forward = True
.Wrap = wdFindStop
.Execute
End With
If Not rngResult.Find.Found Then Exit Do
Set f = rngResult.Font.Duplicate
With rngResult
.Font.Reset
.Style = styFilename
.Font = f
.MoveStart wdWord
.End = rngToSearch.End
End With
Set f = Nothing
Loop Until Not rngResult.Find.Found
'Look for plain text
Do
With rngResult.Find
.ClearFormatting
.Format = True
.Font.Italic = False
.Font.Bold = False
.Font.Underline = wdUnderlineNone
.Forward = True
.Wrap = wdFindStop
.Execute
End With
If Not rngResult.Find.Found Then Exit Do
Set f = rngResult.Font.Duplicate
With rngResult
.Font.Reset
.Style = styFilename
.Font = f
.MoveStart wdWord
.End = rngToSearch.End
End With
Set f = Nothing
Loop Until Not rngResult.Find.Found
Else
'If Response = vbNo
MsgBox ("Document will not be changed")
Exit Sub
End If
Application.StatusBar = ""
ErrorHandler:
Select Case Err.Number
'Style name already exists
Case 5173
Set styFilename = doc.Styles(strFilename)
GoTo BeginHere
End Select
End Sub
Thanks!
Caren Tag: Need to find the web wizzard in office Tag: 66301
Function DayLightSavingsTime
Any suggestions regarding a way to determine if day light savings time is in
effect.
Thanks in Advance.
--
Tim Shaffer Tag: Need to find the web wizzard in office Tag: 66299
Date format in Message
lastMod = ActiveDocument.CustomDocumentProperties("ModificationDate").Value
If MsgBox("The document modification date is " & lastMod & _
". Do you want to change" & " the document modification date
to today's date?", vbYesNo) = vbYes Then
ActiveDocument.CustomDocumentProperties("ModificationDate").Value =
Date
...
The date is shown with both Date/Time, but I want it to be displayed as a
date only. What do I need to do to get the desired format?
ModificationDate is a Custom Property of the document and is in DATE format.
Thanks in advance
Barb Reinhardt Tag: Need to find the web wizzard in office Tag: 66295
How can I remove my com addin from the Words?
I have created an Word com addin .dll with a commandBar and registered with
the Words. The problem is that every time I modified my codes, more buttons
are created on the Words commandBar list. How can I remove my com addin
from the Words?
Thanks.
--
Message posted via http://www.officekb.com Tag: Need to find the web wizzard in office Tag: 66293
How do I change the path of the Word.WdWordDialog.wdDialogFileOpen?
I want to be able to change the file path from the default "My documuent"
path to something like "e:\test\doc\", see the codes below:
private void WordDialog()
{
object m = Type.Missing;
Word.Dialog dlg =
thisApplication.Dialogs
[Word.WdWordDialog.wdDialogFileOpen];
Type dlgType = typeof(Word.Dialog);
string path = selectedServerPath;
// Set name property of dialog box.
dlgType.InvokeMember("Name",
System.Reflection.BindingFlags.SetProperty |
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance,
null, dlg, new object[] {"e:\\test\\doc\\*.doc"});
// Display dialog box.
dlg.Show(ref m);
Close();
}
The code still gives me the "My documuent" path, when this method is
called. How can I fix it? Thanks.
--
Message posted via http://www.officekb.com Tag: Need to find the web wizzard in office Tag: 66292
AttachedTemplate
In Word VBA help is an example how to change the AttachedTemplate of a
document:
ActiveDocument.AttachedTemplate = "C:\Templates\Letter.dot"
But when I use this example with my template,
there is always error 5947: document template cannot be changed.
I want to change the template of a lot of Normal based documents,
so how can I do this without getting this error? Tag: Need to find the web wizzard in office Tag: 66288
What's the use rand() function in Microsoft Word?
Dear Developers,
.At present I am using Microsoft Office XP version .There is something
amazing happens with me.......that if I typed =rand(200,99) in Microsoft Word
and after Pressing an Enter key.....It displays "The quick brown fox jumps
over the lazy dog" and fills 235 pages of the document with the above
line..........I couldn't understand Why it happens?.....Can u help me in this
matter.
Plz reply me as soon as possible
Waitng for ur positive reply Tag: Need to find the web wizzard in office Tag: 66286
How to check the selection is empty after cut?
Hi,
I have the macro that use vba to select the whole text of the current
document consider of a lot of pages and do cut and paste to a new document
as separate pages. But the problem is if my current document is a blank
document, how do i check that it is a blank and the macro will not select
and do cut and paste as i have encountered run time error when the current
document is blank.
please advise. thanks.
regards,
ben Tag: Need to find the web wizzard in office Tag: 66280
How to shift up lines in a Word template (.dot) when previous row.
In a Word template created for users to enter row values, if a value is
desired to be left blank, how can I shift up the following rows to fill the
line left blank? Tag: Need to find the web wizzard in office Tag: 66276
VB Help
When I try to run a Word macro named UpdateTOC, I receive a "Run time error
'5678': Word cannot find the requested bookmark." message.
When I click the "debug" button, I'm taken to this line within the code:
"Selection.GoTo What:=wdGoToBookmark, Name:="toc""
This is the rest of the code:
```````````````````
Sub UpdateTOC()
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToBookmark, Name:="toc"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
With ActiveDocument
.TablesOfContents.Add Range:=Selection.Range,
RightAlignPageNumbers:= _
True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _
LowerHeadingLevel:=4, IncludePageNumbers:=True, AddedStyles:=""
.TablesOfContents(1).TabLeader = wdTabLeaderDots
End With
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToBookmark, Name:="tocend"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeParagraph
End Sub
`````````````
Can anyone provide any insight in two what is going on or attempting to
happen? I have no experience in VB coding, so laymans terms may be necessary
to explain it. ;-)
Thanks. Tag: Need to find the web wizzard in office Tag: 66274
I give up...
I am either too tired to think straight or I am overlooking something
simple here...
Here is the background:
Word 2003.
A document contains some characters that are formatted with the Symbol font
and that were inserted with the Insert Symbol dialog.
The same document also contains "(" that are meaningful.
A macro is looking for those "(" but since AscW(Selection.Text) returns 40
for the "(" and for the Symbol font characters, we need to tell if the
character is really a "(" or not. We do not care what symbol it is, as long
as we can tell the symbol apart from the "(".
So, I came up with this macro using some of the clever code I found from
Klaus Linke:
'_______________________________________
Sub MainMacro()
Dim MyRange As Range
Dim CheckCar As Range
Set MyRange = Selection.Range
For Each CheckCar In MyRange.Characters
If AscW(CheckCar) = 40 Then
If CheckIfSymbol(CheckCar) Then
MsgBox "Ne pas traiter ce caractère."
Else
MsgBox "Traiter cette parenthèse."
End If
End If
Next
End Sub
'_______________________________________
'_______________________________________
Function CheckIfSymbol(MyCar As Range) As Boolean
CheckIfSymbol = False
With Selection.Find
.Text = "[" & ChrW(61472) & "-" & ChrW(61695) & "]"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute
If .Found Then
MsgBox "Ce n'est pas un parenthèse ouvrante"
CheckIfSymbol = True
End If
End With
End Function
'_______________________________________
Basically, I check every character that are selected, if I find that one of
them is a "(", I double check to make sure that it really is a "(" and not a
symbol.
Here is the problem:
With
.Wrap = wdFindStop
in the function, the .Found property is always false, even if a symbol is
currently selected.
If I change
.Wrap = wdFindStop
to
.Wrap = wdFindContinue
Then the .Found property is always true because it always finds the symbol
character in the document, even if it is not in the original selected range.
Why is the Find actually working to tell symbols apart from "(" when doing a
document wide search, but not when checking a specific character?
I have done this before, but not with symbol characters. I remember doing
this to tell if a selected character was a section break or a page break. I
used basically the same kind of code and it worked without any problem. This
isn't working and I cannot tell why! Something to do with wild cards?
Arrrggghhh! I need a coffee!
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org Tag: Need to find the web wizzard in office Tag: 66271
Word Replace Function
Hi
I am using Word 2003 and am trying to figure out if there is a way to
restrict the Replace functionality to only search/replace in the document
header/footer.
When the document opens up, the user is presented with a form. One of the
fields they enter into the form will be used for the Search/Replace.
Thanks in advance Tag: Need to find the web wizzard in office Tag: 66264
Find, Cut, then Paste Methodology
I have a number of documents that have questions in one part of a document
and the corresponding answers in another part of the document. I need to
modify the document to have the answer four lines after the associated
question.
I need to be able to:
1) loop through the document,
2) find "question 1",
3) go down 4 lines and mark that location as the place to paste "answer 1",
4) then find "answer 1",
5) cut "answer 1" and paste in the new location for "answer 1".
6) loop to the next question number.
Can anyone help me get started?
Thanks in advance,
Raul Tag: Need to find the web wizzard in office Tag: 66253
Styles that inherit
Is it possible in Word to define styles that inherit margins from the
paragraph that precedes? IOW, I would like to define, say "Bullet" to
indent 0.2 in from the left of the margin, with "margin" being defined
by the style of the previous paragraph. "Bullet" therefore is always
indented 0.2" in from whatever is above it. TIA Tag: Need to find the web wizzard in office Tag: 66252
Adding FormFields
G'day there One & All,
Please accept my apology if I've come to the wrong NG, although
the name seems inclusive of pretty much everything related to Word VP
Programming =).
I'm currently trying to write a bit of a Word application. I'm not
a trained, nor even a practised, macro writer but I have had a little
success with Excel applications for my employer. I'm still trying to
come to grips with Word's way of doing things and I've struck
difficulties.
I have a document with a table at the top of the page. It has only
a single row with 4 cells. The first contains day & date fields which I
have working the way I want. The next 3 cells are causing my problems.
After the headings I'm trying to get FormFields for data entry as
follows:
Name: Shift: Number:
[ ] [ ]-[ ] [ ]
As you can probably guess, the "Shift" fields are for start &
finish times. I'll write a macro to add 8 hours to the start time to
automatically enter the end time. Name & Number need nothing fancy.
I have 2 command buttons included which are labelled "+" & "-".
What I'm trying to do is to have the first one add a row of fields under
what's already there:
Name: Shift: Number:
[ ] [ ]-[ ] [ ]
[ ] [ ]-[ ] [ ]
...and the latter one bring up a form to select a name and remove the
fields associated with it.
I can make & manipulate the userform without any problem, but I
can't figure out how to make the fields appear where I want them
(immediately below the others, in the same cells).
I could probably get it to work by making a nested table of only
one column width for each field - code for which I found on a forum
somewhere - but although that was suitable for the forum member's
situation, that seems to be just a workaround here. Surely there must be
some way to position text entry formfields when you make them.
Can anybody please shed some light on this for me?
Thanks in advance,
Ken McLennan
Qld, Australia Tag: Need to find the web wizzard in office Tag: 66249
Reading info from styles
Hi Folks,
I'm trying to find a quick and dirty way of reading the Tab information
(Alignment & leader), Bullet information (whether bulleted, Numbered or
Outline Numbered and all the customizations) and Border settings from a
style.
Any pointers, Especially on the Tab and Numbering, would be grately
appreciated.
Thanks
J Tag: Need to find the web wizzard in office Tag: 66248
inserting name and country inside the letter
i have two word document, one include atable which include the name and the
country, and i have a letter which i have to get each name and country from
the table and entering it to the letter then printing it
regards,
--
*******************
Ahmad Baqleh Tag: Need to find the web wizzard in office Tag: 66246
Html Codes
What is the HTML code for:
- a drop down menu
- a submit button
- a list box
PLEASE HELP ME!!! Tag: Need to find the web wizzard in office Tag: 66243
Array with error memorisation
Thanks for your answers,
But now I need to create an error memorisation of the previous calulation I
made in my matrix.
And sort those results.
I'm trying to do it with LNo algo, but I can fix one bug.
The first item should be which one? how do I initialise the i var of the
algo?
If you can help me thanks a lot!!
Cheers
Mathew Tag: Need to find the web wizzard in office Tag: 66239
Need some help with VBA as it applies to Word AutoFormat
Here is the problem in a nutshell:
I launch Word thru automation.
I then populate tabular data into a document that I obtain from a
database
I format the data using the AutoFormat property off the table object
I save the document as an HTML file.
>From what I can see, the HTML file is saved, but the data looks to be
missing.
So, instead of saving it to an HTML file, I saved it to a DOC file.
Then, I see what the problem is -- the formatting has not been applied
(or completed) prior to saving the document. If I format it, or change
the formatting, I find that the data is correct.
I try this without automation, and what I find is that for a large
table, the data is populated first, and the formatting takes place
(likely) in the background, and takes some time to finish.
What is likely happening is that the save occurs before the formatting
has completed.
Any way to solve this problem, such that I can wait for some event or
some flag to be set before I initiate the save operation?
Are there properties in the Word object or its sub-objects that I can
set to achieve the desired result? Something along the lines of a
non-background formatting?
Any pointers would be a big help.
Thanks in advance. Tag: Need to find the web wizzard in office Tag: 66228
How can I load a library in a Macro.
I have to make a macro that calls a library to show several forms when the
user press the macro-button before the document is saved.
I remember I have done so with word 97 using LoadLibrary("file.dll"), but
with word 2k it seams it is not possible.
Does anybody know if it is possible to use this api in word2000.
Regards. Tag: Need to find the web wizzard in office Tag: 66220
Style formatting through VBA
This is a multi-part message in MIME format.
------=_NextPart_000_000F_01C53944.14BE1C90
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
I have been doing customizations for companies (mostly law firms) from =
Word 6 through 2000. When setting up their styles, I use the following =
method:
=20
First, I insert dummy text by typing =3Dand(10,5) to insert 10 =
paragraphs, with 5 sentences each. Then, in each paragraph, I apply the =
required formatting and save the style name. =20
=20
When I am done, I have a bunch of paragraphs with the text: "The quick =
brown fox jumps over .", and it is not clear what style is applied =
without looking at the stylename name drop-down list.
=20
So, I created the following macro which loops through all paragraphs in =
the document. It turns on the Bold attribute, inserts the name of the =
style at the beginning of the paragraph and then turns off the Bold =
attribute. =20
Sub StyleName()
Dim opara As Paragraph
For Each opara In ActiveDocument.Paragraphs
If opara.Style <> "Normal" Then
Selection.Font.Bold =3D wdToggle
opara.Range.InsertBefore Text:=3DFormat(opara.Style.NameLocal & ". =
")
Selection.Font.Bold =3D wdToggle
End If
Next opara
End Sub
=20
This method has worked very good for Word 97 and Word 2000. However, it =
does not work for Word XP or Word 2003. I have split the window and =
watched how it works as I step through the macro (pressing F8). I see =
it turn bold on, then it goes to the beginning of the paragraph (before =
the bold on command which effectively turns bold off), inserts the name =
of the style, then does the Bold toggle, but since it was just turned =
off before it inserted the text, it is now turning Bold on after the =
text has been inserted and the text is not bold. =20
=20
Any suggestions on how I can make this work in Word 2003?
=20
Thanks,
Anne
=20
------=_NextPart_000_000F_01C53944.14BE1C90
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2604" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3DArial=20
size=3D2>Hi,</FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3DArial=20
size=3D2></FONT> </P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3DArial =
size=3D2>I have=20
been doing customizations for companies (mostly law firms) from Word 6 =
through=20
2000. <SPAN style=3D"mso-spacerun: yes"> </SPAN>When setting up =
their styles,=20
I use the following method:</FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><?xml:namespace =
prefix =3D o ns =3D=20
"urn:schemas-microsoft-com:office:office" /><o:p><FONT face=3DArial=20
size=3D2> </FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2>First, I insert dummy text by typing =3Dand(10,5) to insert 10 =
paragraphs,=20
with 5 sentences each. <SPAN style=3D"mso-spacerun: =
yes"> </SPAN>Then, in=20
each paragraph, I apply the required formatting and save the style name. =
<SPAN=20
style=3D"mso-spacerun: yes"> </SPAN></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2> </FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3DArial =
size=3D2>When I am=20
done, I have a bunch of paragraphs with the text: <SPAN=20
style=3D"mso-spacerun: yes"> </SPAN>=93The quick brown fox jumps =
over =85=94, and=20
it is not clear what style is applied without looking at the stylename =
name=20
drop-down list.</FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2> </FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT size=3D2>So,=20
I created the following macro which loops through all paragraphs in the=20
document. <SPAN style=3D"mso-spacerun: yes"> </SPAN>It turns on the =
Bold=20
attribute, inserts the name of the style at the beginning of the =
paragraph and=20
then turns off the Bold attribute.<SPAN style=3D"mso-spacerun: =
yes"> =20
</SPAN></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"mso-spacerun: yes"><FONT face=3DArial =
size=3D2></FONT></SPAN> </P><SPAN=20
style=3D"mso-spacerun: yes">
<P><FONT face=3DArial size=3D2>Sub StyleName()</FONT></P>
<P><FONT face=3DArial size=3D2>Dim opara As Paragraph</FONT></P>
<P><FONT face=3DArial size=3D2>For Each opara In=20
ActiveDocument.Paragraphs</FONT></P>
<P><FONT face=3DArial size=3D2> If opara.Style =
<> "Normal"=20
Then</FONT></P>
<P><FONT face=3DArial size=3D2> =20
Selection.Font.Bold =3D wdToggle</FONT></P>
<P><FONT face=3DArial size=3D2> =
opara.Range.InsertBefore=20
Text:=3DFormat(opara.Style.NameLocal & ". ")</FONT></P>
<P><FONT face=3DArial size=3D2> Selection.Font.Bold =
=3D=20
wdToggle</FONT></P>
<P><FONT face=3DArial size=3D2>End If</FONT></P>
<P><FONT face=3DArial size=3D2>Next opara</FONT></P>
<P><FONT face=3DArial size=3D2>End Sub</FONT></P></SPAN>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2> </FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT =
face=3DArial><FONT=20
size=3D2>This method has worked very good for Word 97 and Word=20
2000. However, it does not work for Word XP or Word =
2003.<SPAN=20
style=3D"mso-spacerun: yes"> </SPAN>I have split the window and =
watched how=20
it works as I step through the macro (pressing F8).<SPAN=20
style=3D"mso-spacerun: yes"> </SPAN>I see it turn bold on, then it =
goes to=20
the beginning of the paragraph (before the bold on command which =
effectively=20
turns bold off), inserts the name of the style, then does the Bold =
toggle, but=20
since it was just turned off before it inserted the text, it is now =
turning Bold=20
on after the text has been inserted and the text is not bold.<SPAN=20
style=3D"mso-spacerun: yes"> </SPAN></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2> </FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3DArial =
size=3D2>Any=20
suggestions on how I can make this work in Word 2003?</FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2> </FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2>Thanks,</FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2>Anne</FONT></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p><FONT =
face=3DArial=20
size=3D2> </FONT></o:p></P></DIV></BODY></HTML>
------=_NextPart_000_000F_01C53944.14BE1C90-- Tag: Need to find the web wizzard in office Tag: 66215
AutoText
This is a multi-part message in MIME format.
------=_NextPart_000_0006_01C5393F.83374ED0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I have some questions about creating AutoText entries. This is going to =
be long-winded so bear with me, because there is a very specific reason =
for doing this.
=20
I have been using the following code using two input boxes to create =
AutoText entries, and either assign that entry to an existing category =
(such as Mailing Instructions) or create a new category (such as =
Stamps). =20
=20
Public Sub CreateNewAutoText()
Dim strATName As String
Dim strATCategory As String
'Get the AutoText Name
Dim Message, Title
Message =3D "Enter the name for the AutoText Entry" ' Set prompt.
Title =3D "Create AutoText Entry" ' Set title.
strATName =3D InputBox(Message, Title)
=20
'Get the AutoText Category
Dim atMessage, atTitle
Message =3D "Enter the category for the AutoText Entry" ' Set prompt.
Title =3D "Create AutoText Entry" ' Set title.
strATCategory =3D InputBox(atMessage, atTitle)
=20
Selection.CreateAutoTextEntry strATName, strATCategory
End Sub
=20
This has worked very well, using input boxes. I have now set it up with =
a userform (which basically works the same as the above). Following is =
the code for the userform:
=20
Public strATCategory As String
Public strATName As String
Private Sub cmdCancel_Click()
Unload Me
End Sub
=20
Private Sub cmdOK_Click()
Selection.CreateAutoTextEntry strATName, strATCategory
Unload Me
End Sub
=20
Private Sub txtATCategory_Change()
strATCategory =3D txtATCategory.Text
End Sub
=20
Private Sub txtATName_Change()
strATName =3D txtATName.Text
End Sub
=20
Using either of the above methods, an AutoText entry is created in =
Normal.dot. This is fine for most users on the network, however, I =
would like to extend the macro for IT staff so that when they create a =
new AutoText entry that should be firmwide, it can be created in their =
global template (currently SKGlobal.dot) and distributed to users, =
without overwriting the user's Normal.dot. =20
=20
I know that most consultants recommend locking down Normal.dot (making =
it read only), but if you do this, you disable any customization on the =
user's part. They cannot create new AutoText, formatted AutoCorrect, =
Macros, or custom toolbars. This slows productivity on their part. =
What I do for my clients is create a new template that all new documents =
are based on (i.e., SKBlank.dot). The File, New menu option and the =
blank document icon on the standard toolbar (and the Word icons on the =
desktop or Programs menu) are remapped so that all new documents not =
based on another template (such as letter, memo, fax, etc) are based on =
this template rather than on Normal.dot. This way, the users can have =
access to store customizations of their own in Normal.dot.
=20
I would like to extend the above userform for the IT staff at the =
company to create new AutoText entries in their global template (in this =
case, SKGlobal.dot) rather than in Normal.dot. =20
=20
I have done some testing with the above procedures. They both work very =
well for creating AutoText entries in Normal.dot, with the name you =
specify and creating a new category if needed. All new entries created =
are stored in Normal.dot. However, if I then try to copy the new =
entries to the SKGlobal.dot, they are copied in a different way. Each =
entry is copied with the name of the AutoText entry as a category and as =
an AutoText entry under that category with the same name. For example, =
I previously created AutoText entries named Draft and Draft Autodate =
under the category Stamps, which was stored in Normal.dot. If I use the =
Organizer to copy those entries into SKGlobal.dot, then choose Insert, =
AutoText, I will see a category in the drop down list named Draft, which =
has an AutoText entry named Draft and a Category named Draft Autodate, =
which has an AutoText entry named Draft Autodate. =20
=20
Is there anyway when using either of the above methods of creating new =
AutoText entries that I can specify the template that the AutoText =
should be stored in?
=20
Sorry for the long-winded message, but I am desparate here.
Anne
------=_NextPart_000_0006_01C5393F.83374ED0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2604" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">I have some questions =
about creating=20
AutoText entries. This is going to be long-winded so bear with me, =
because=20
there is a very specific reason for doing this.</SPAN><?xml:namespace =
prefix =3D o=20
ns =3D "urn:schemas-microsoft-com:office:office" /><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"> <o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">I have been using the =
following code=20
using two input boxes to create AutoText entries, and either assign that =
entry=20
to an existing category (such as Mailing Instructions) or create a new =
category=20
(such as Stamps).<SPAN style=3D"mso-spacerun: yes"> =20
</SPAN></SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p> </o:p></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Public Sub=20
CreateNewAutoText()<BR>Dim strATName As String<BR>Dim strATCategory As=20
String</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">'Get the AutoText =
Name<BR>Dim=20
Message, Title<BR>Message =3D "Enter the name for the AutoText=20
Entry" ' Set prompt.<BR>Title =3D "Create AutoText=20
Entry" ' Set title.<BR>strATName =3D InputBox(Message, =
Title)</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"> <o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">'Get the AutoText =
Category<BR>Dim=20
atMessage, atTitle<BR>Message =3D "Enter the category for the AutoText=20
Entry" ' Set prompt.<BR>Title =3D "Create AutoText=20
Entry" ' Set title.<BR>strATCategory =3D =
InputBox(atMessage,=20
atTitle)</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"> <o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"> =20
Selection.CreateAutoTextEntry strATName, strATCategory<BR>End=20
Sub</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p> </o:p></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">This has worked very well, =
using=20
input boxes. I have now set it up with a userform (which basically =
works=20
the same as the above). Following is the code for the=20
userform:</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"> <o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Public strATCategory As=20
String<BR>Public strATName As String</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Private Sub=20
cmdCancel_Click()<BR> Unload Me<BR>End=20
Sub</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"> <o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Private Sub=20
cmdOK_Click()<BR> Selection.CreateAutoTextEntry =
strATName,=20
strATCategory<BR> Unload Me<BR>End =
Sub</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"> <o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Private Sub=20
txtATCategory_Change()<BR>strATCategory =3D txtATCategory.Text<BR>End=20
Sub</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"> <o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Private Sub=20
txtATName_Change()<BR>strATName =3D txtATName.Text<BR>End=20
Sub<o:p></o:p></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p> </o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Using either of the above =
methods,=20
an AutoText entry is created in Normal.dot. This is fine for most =
users on=20
the network, however, I would like to extend the macro for IT staff so =
that when=20
they create a new AutoText entry that should be firmwide, it can be =
created in=20
their global template (currently SKGlobal.dot) and distributed to users, =
without=20
overwriting the user=92s Normal.dot.<SPAN style=3D"mso-spacerun: =
yes"> =20
</SPAN><o:p></o:p></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p> </o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">I know that most =
consultants=20
recommend locking down Normal.dot (making it read only), but if you do =
this, you=20
disable any customization on the user's part. They cannot create =
new=20
AutoText, formatted AutoCorrect, Macros, or custom toolbars. This =
slows=20
productivity on their part. What I do for my clients is create a =
new=20
template that all new documents are based on (i.e., SKBlank.dot). =
The=20
File, New menu option and the blank document icon on the standard =
toolbar (and=20
the Word icons on the desktop or Programs menu) are remapped so that all =
new=20
documents not based on another template (such as letter, memo, fax, etc) =
are=20
based on this template rather than on Normal.dot. This way, the =
users can=20
have access to store customizations of their own in=20
Normal.dot.</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p> </o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">I would like to extend the =
above=20
userform for the IT staff at the company to create new AutoText entries =
in their=20
global template (in this case, SKGlobal.dot) rather than in =
Normal.dot. =20
<o:p></o:p></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p> </o:p></SPAN></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">I have done some testing =
with the=20
above procedures. They both work very well for creating AutoText =
entries=20
in Normal.dot, with the name you specify and creating a new category if=20
needed. All new entries created are stored in Normal.dot. =
However,=20
if I then try to copy the new entries to the SKGlobal.dot, they are =
copied in a=20
different way. Each entry is copied with the name of the AutoText =
entry as=20
a category and as an AutoText entry under that category with the same=20
name. For example, I previously created AutoText entries named=20
Draft and Draft Autodate under the category Stamps, which was =
stored in=20
Normal.dot. If I use the Organizer to copy those entries into =
SKGlobal.dot, then choose Insert, AutoText, I will see a category in the =
drop=20
down list named Draft, which has an AutoText entry named Draft and a =
Category=20
named Draft Autodate, which has an AutoText entry named Draft =
Autodate. =20
</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p> </o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">Is there anyway when =
using either=20
of the above methods of creating new AutoText entries that I can specify =
the=20
template that the AutoText should be stored in?</P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p> </o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">Sorry for the =
long-winded=20
message, but I am desparate here.</P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3DArial=20
size=3D2></FONT> </P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in =
0pt">Anne</P></BODY></HTML>
------=_NextPart_000_0006_01C5393F.83374ED0-- Tag: Need to find the web wizzard in office Tag: 66212
GetSpellingSuggestions problem
Can anyone please suggest to me why the second call to
GetSpellingSuggestions() below raises an exception when the first one works
fine?
VarCustDict := 'C:\myPath\myDictionary.dic';
VarLang := wdEnglish;
VarDict := fWordApp.Languages.Item(varLang).NameLocal;
lSuggestions :=
fWordDoc.Range.GetSpellingSuggestions(VarCustDict,
EmptyParam,
VarDict,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam);
VarLang := wdFrench; // for example...
VarDict := fWordApp.Languages.Item(varLang).NameLocal;
lSuggestions :=
fWordDoc.Range.GetSpellingSuggestions(VarCustDict,
EmptyParam,
VarDict,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam,
EmptyParam);
Regards,
AndrewFG Tag: Need to find the web wizzard in office Tag: 66208
How can I use a template and avoid the read only message that ap.
Hi, I'm trying to use a receipe book template from microsoft office and as a
proyect of my home economics class. I can't write any receipe to the
rewritable disc becase it appears a message of "read only document " and my
students said that also. I copied the template to every rewritable disc that
I ask for the proyect and I can't copy any information into the template once
it is in the disc. anything can't be saved because of the read only message.
How can I avoid this and prepare the document to be use by the students in
order to create their own receipe books for the class.
Thank You
Luisa Montero Hme Economics class teacher Tag: Need to find the web wizzard in office Tag: 66207
Copy SQL table to Access from Word vba
Hi all,
I have a word application that uses a local Access database. This Access
database I need to updated from a SQL server.
I would like to copy a table from the SQL to the access database like this:
- all data in the Access database are lost
- the SQL table are copied to the Access database, not row by row but simply
copied (this I belive should give more speed)
Can anybody point me in the right direction or even better show me some code
that works
Thanks,
Flemming Tag: Need to find the web wizzard in office Tag: 66204
change mulptile fields across several doc's
Is there a way to change fields across several different documents? We have
roughly 148 different document templates. Is there a way to set up fields in
these so that we can run a batch or something simmilar to change the headers
and footers on these files to match the project they will be applied to.
Probably a total of 2 -7 fields per document.
Project Name
Project ID
Contract #
and a couple more
Having to go through these all by hand to set up new projects takes to much
time...
thanks Tag: Need to find the web wizzard in office Tag: 66203
Vba to read column of text
Hi,
Is there a way using vba that can copy a particular column of the text that
i want and put into the column of the new file.
For example:
Existing colum
Name Age
Lee 23
tan 34
rich 34
Copy the column of the name and paste it into new file of a new column as
below:
Name
lee
tan
rich
please advise.
thanks.
regards,
ben Tag: Need to find the web wizzard in office Tag: 66199
I have save a document to web and then try to go to web wizzard but can't
find it in the list of wizzards in my office 03. Can anyone help