wdDialogEditAutoText
Hi, I was hoping someone could help me out. These are the arguments for
wddialogeditautotext: Name, Context, InsertAs, Insert, Add, Define,
InsertAsText, Delete, and CompleteAT
So which argument would I use to set the template to a specific template of
my choosing when calling the command wddialogeditautotext in a vba program?
Thanks for any help?
--
-Kirsten Tag: Can you use VBA to create a pie chart in Word Tag: 58258
page header to be actual header of paragraph of each page
Hi there,
we would like to have the name of the paragraphs header of the actual
page as the page header.
e.g:
page 1: paragraph header: Introduction
pager header left hand side: Introduction
page 2: paragraph header: Characteristics
pager header left hand side: Characteristics
In case there are two paragraph headers on one page we would like to
have the first one as the page header.
In case there is no paragraph header on the page we would like to have
the header of the previous page as the page header.
Can this be done?
Thank you very much.
Regards,
Norbert + Warren Tag: Can you use VBA to create a pie chart in Word Tag: 58247
Expand comment scope
Hi all,
is there any way to expand the comment scope range with VBA? Comment.Scope
property is read-only :(
Thanks
Marco Tag: Can you use VBA to create a pie chart in Word Tag: 58245
macro for spaces needed
have a peculiar problem happening with a document. When
it converts to rtf (from another format, not important),
it is producing lots of extra spaces between words.
Curious if anyone can provide a simple macro text that
will search through the document for more than one space
sections and replace them with single spaces. Would help
greatly. Thanks.
Boris Tag: Can you use VBA to create a pie chart in Word Tag: 58242
Smart Tags add Outlook Address
I would like to include two additional fields with the basic mailing address
used with Smart Tags in Word 2003 from Outlook. The fields for Company and
Job Title should also be included with the Smart Tag. How can I do that? Do
I have to purchase third-party software? Thanks in advance. Tag: Can you use VBA to create a pie chart in Word Tag: 58241
How to delete text between { }
Hi There,
Would you please let me know how to delete a text between {}?
Thanks,
Leila Tag: Can you use VBA to create a pie chart in Word Tag: 58237
Help with App.FileSearch object, please?
I'm trying to loop through the files in a folder to use FileCopy. The files
have no dot-extension suffix, and FIleSearch can't see them. If I rename
them with a .doc, it works great. Can someone help me tweak this? Or give
me a better method?
Ed
With fs
.LookIn = strPath & "\MyDocs"
.FileName = "*.doc" 'for no extension,
'I used "*"
If .Execute > 0 Then 'with no extension,
'this drops immediately to End If
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
strName = .FoundFiles(i)
strFName = Right(strName, Len(strName) - 9)
MsgBox strFName
FileCopy strName, strFolder & strFName
Next i
End If
End With Tag: Can you use VBA to create a pie chart in Word Tag: 58233
can anyone see what's wrong with this ?
can anyone see what's wrong with this
it spose to iterate through all picture objects & cut n paste them back
it errors on the very first picture (item(1)) it finds
With ActiveDocument
If .Shapes.Count > 0 Then
With .Shapes
For x = 1 To .Count
.Item(x).Select
Selection.Cut
Selection.PasteAndFormat (wdPasteDefault) <<<<<<<<<<<
error here (on item 1)
Next
End With
End If
If .InlineShapes.Count > 0 Then
With .InlineShapes
For x = 1 To .Count
.Item(x).Select
Selection.Cut
Selection.PasteAndFormat (wdPasteDefault)
Next
End With
End If
End With Tag: Can you use VBA to create a pie chart in Word Tag: 58231
Mail merge from Excel to Word
Hi,
I am trying to figure out how to right the code to perform a mail merge from
excel to a word file. The excel source is about 20 columns and the number of
rows will vary. Each item will be on a separate row with each column
representing information about that item. I would like each item to be on
it's own page in the word document. I was thinking of creating a word
template that would be a starting point and then doing a catalog type merge.
any help with the code, especially the new page for each row of data would be
appreciated.
Thanks,
Mike Tag: Can you use VBA to create a pie chart in Word Tag: 58230
wavy underlined content
Can I access just the wavy underlined words in word grammar errors through a
(visual basic) macro? Tag: Can you use VBA to create a pie chart in Word Tag: 58229
Selection Object
Hello,
I create a word document from vb application. I format the
header and footer and insert a couple of files into the
word documment. I use the selection object for both
formatting header and footer and inserting files. It works
fine the first time I run the program. But the second
time when I run it. The files did not inserted into the
document.
Here is the code I use to format footer:
objWord.Sections(1).Footers
(wdHeaderFooterPrimary).Range.Fields.Add
Range:=Selection.Range, Type:=wdFieldPage
Selection.TypeText Text:=" of "
objWord.Sections(1).Footers
(wdHeaderFooterPrimary).Range.Fields.Add
Range:=Selection.Range, Type:=wdFieldNumPages
Selection.ParagraphFormat.Alignment =
wdAlignParagraphCenter
After I format the document footer, I have the follwoing
line of code:
objWord.Content.Select
With Selection
Insert file here
end with
It looks like the selection is still in the footer area.
Is it anyway I can detect where the selection is and how
to redefine the selection?
Thanks for any help!
Mei Tag: Can you use VBA to create a pie chart in Word Tag: 58225
Updating autotext
I have a variety of autotext entries. Unfortunately, we have to constantly
revise and update these autotext entries back to the template (or even add
new entries). It's hard to explain to others how to do this.
So... here's my problem. I'd like to use VBA to create a menu that would
walk people through the process (highlighting the correct text,
automatically selecting the correct template, etc...).
Has someone already done this? Right now, I was pondering having a button on
the main menu (it's this whole big menu we have for inserting spec entries,
not to worry about that part) that says "update entry", then when you click
that button, the main menu is hidden while a msgbox pop up that says
"highlight text".You would press okay to get rid of the message box,
highlight the text, then... then... then I get a bit lost.
I want it to then pull up the resident wdDialogEditAutoText dialog box, but
and have it set automatically to the correct template (I think that will get
rid of a lot of confusion) but don't know how to force the dialog box to set
to a specific template in the "Look in" area.
I also don't know how you would go from highlighting text to bringing up
this dialog box.
If you need clarification on what I'm trying to do, feel free to ask.
Thanks in advance!
--
-Kirsten Tag: Can you use VBA to create a pie chart in Word Tag: 58224
Pass document reference into another doc?
I want the Document_Open macro in one doc to open another doc. The second
doc also has a Document_Open macro, and the first doc stays open until the
second doc is finished. Can I pass the object reference from the first doc
to the second so the second can completely close that instance of Word? Or
set a reference while the doc is open with a macro running and cause it to
close?
Ed Tag: Can you use VBA to create a pie chart in Word Tag: 58216
Error 462 problem.
I've written an Access 2000 app which creates some Word documents. There
is one place that it errors randomly on error 462 - The remote server
machine does not exist or is unavailable. To give an idea as to the
randomness, I ran it over 100 times yesterday on one PC (Win 2000 + Office
2000) and it never failed. On another machine running Win XP + Office XP
Standard + Access 2000, it fails about 80% of the time. On a 3rd PC,
identical to the 2nd, it fails less than 10% of the time.
And on any PC, if you step through the code, it never fails.
The pertinent parts of the code follows, with the point where it fails
indicated thus: ----->
Note that some code has been omitted for clarity/brevity.
----------------------------------------------------------------------
Dim objWord As Word.Application
Set objWord = GetObject(, "Word.Application")
objWord.Documents.Add Application.CurrentProject.Path & _
cStrWordTemplate
'----------------------------------------------------------------------
' Put in the header
'----------------------------------------------------------------------
With objWord
' .ScreenUpdating = False
' .Visible = False
.Selection.Goto What:=wdGoToBookmark, Name:="bkShopType"
.Selection.TypeText Text:=strShopType
.Selection.MoveRight unit:=wdCell, Count:=2
.Selection.TypeText Text:="Dealer " & _
rst.Fields("DealerID") & _
" - " & rst.Fields("Dealer Name")
.Selection.MoveRight unit:=wdCell
.Selection.TypeText Text:=strWave
.Selection.EndKey unit:=wdStory
.Selection.TypeParagraph
'----------------------------------------------------------------------
' Loop through the recordset and find all the questions where
' points were lost
'----------------------------------------------------------------------
Do While Not rst.EOF
If rst.Fields("PointsScored") < _
rst.Fields("PointsAvailable") Then
'----------------------------------------------------------------------
' Create the table to hold the data
'----------------------------------------------------------------------
.Selection.EndKey unit:=wdStory
.Selection.TypeParagraph
.ActiveDocument.Tables.Add Range:=.Selection.Range, _
NumRows:=1, NumColumns:=1, _
DefaultTableBehavior:=wdWord9TableBehavior, _
AutoFitBehavior:=wdAutoFitFixed
-----> Fails between here and the next 3 lines
.Selection.Tables(1).PreferredWidthType = _
wdPreferredWidthPoints
.Selection.Tables(1).PreferredWidth = _
CentimetersToPoints(19.5)
.Selection.Rows.HeightRule = wdRowHeightAtLeast
.Selection.Rows.Height = CentimetersToPoints(1)
----------------------------------------------------------------------
Anybody see the problem?
--
Roger Tag: Can you use VBA to create a pie chart in Word Tag: 58210
ActiveDocument object doesn't work
Hello all,
I have a problem with VB.Net.
I want to get the readabilityStatistics from word documents. herefore I have
to activate a doc as an ActiveDocument in the Word.Application. And here is
exactly the problem. I cannot use the ActiveDocument as it is written
everywhere in the MSDN!
Here is what I did:
...
Private Sub TestMSWordFunc(ByVal file As String)
'MS Word declarations
Dim wordApp_Server As Word.Application
Dim wordDoc As Word.Document
Dim wordRange As Word.Range
Dim wordStatistic As Word.ReadabilityStatistic
'Other
Dim fileMod As Boolean
Dim resComputeStatistics As Integer
Dim wordEnum As IEnumerator
Dim wordVal As ValueType
'Open an application server first
wordApp_Server = New Word.Application
wordDoc = wordApp_Server.Documents.Open( _
FileName:=file, _
ConfirmConversions:=False, _
ReadOnly:=False, _
AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", _
Revert:=False, _
WritePasswordDocument:="", _
WritePasswordTemplate:="", _
Format:=Word.WdOpenFormat.wdOpenFormatAuto, _
Visible:=False)
'Document must be set active in order to retrieve further information
wordApp_Server.Documents.Add(file)
wordDoc = wordApp_Server.ActiveDocument
Label_ResultFile.Text = file
Label_ResultWords.Text =
wordDoc.ComputeStatistics(Word.WdStatistic.wdStatisticWords)
Label_ResultParagraphs.Text =
wordDoc.ComputeStatistics(Word.WdStatistic.wdStatisticParagraphs)
Label_ResultFK.Text =
wordApp_Server.ActiveDocument.Content.ReadabilityStatistics.Item(6).Value
...
I cannot get to tell the application the open word document!! The last line
always returns zero, as the ActiveDocument is empty,i.e. a different document
than the one I opened!
Can anybody help me?
I am getting crazy. It is probably very easy, but I cannot see the mistake.
Kisses
Mel Tag: Can you use VBA to create a pie chart in Word Tag: 58208
Need Help on User-Defined Type
Word 2000
I'm trying to create a user-define type. This is the first time I've tried
to do this, so I've been reading through the on-line Help trying to figure
it out. Here's what I have so far:
********************
' Code placed in a standard module containing only public declarations.
Type ErrorRecord
ErrDateTime As Date
ModuleName As String
Subroutine As String
ErrNumber As Long
ErrHelpContext As Long
ErrDescription As String
ErrHelpFile As String
End Type
' Code placed in the routine.
Dim ErrorRecord As ErrorRecord
With ErrorRecord
.ErrDateTime = ErrDateTime
.ModuleName = ModuleName
.Subroutine = Subroutine
.ErrNumber = Err.Number
.ErrHelpContext = Err.HelpContext
.ErrDescription = Err.Description
.ErrHelpFile = Err.HelpFile
End With
FileNumber = FreeFile
Open ErrorLog For Random As FileNumber Len = Len(ErrorRecord) + 2
Put #FileNumber, , ErrorRecord
********************
On the PUT statement I get:
Run-time error '59':
Bad record length
From reading the Help on this error, I understand what the problem is, but
I'm having difficulty determining how to set the proper record length.
Hopefully, I've provided enough information for someone to answer my
question. Given the above, how do I get the record length set properly?
-- Tom
State of Montana
Department of Justice Help Desk
"Making the world a safer place." Tag: Can you use VBA to create a pie chart in Word Tag: 58205
FilePrint Question
Word 2000
I have the following subroutine:
Sub FilePrint()
Message = "FilePrint"
PrintRecords
End Sub
My goal here is to have FilePrint run every time the document is printed, no
matter how the user prints the document. When I select "Print" from the
File menu, or use CTRL+P, I get the "FilePrint" message, indicating that the
FilePrint routine ran. However, if I print by clicking the Print button on
the toolbar, I get no message at all, but the document still prints,
indicating that the FilePrint routine is not running when the Print button
on the toolbar is used.
Is there a way to intercept the print operation when the user clicks the
Print button on the toolbar?
I've searched in the VB Help and have come up empty. Currently, the only
solution I can think of is to create a custom toolbar that is identical to
the Standard toolbar, except that the Print button would call the FilePrint
macro.
-- Tom
State of Montana
Department of Justice Help Desk
"Making the world a safer place." Tag: Can you use VBA to create a pie chart in Word Tag: 58200
Drop-down form field, can one create more than a 25 item list?
I am a physician whose documentation requires certain drop-down form text
fields to have drop-down pick lists longer than the default limit of only 25
items. Can anyone help me with the possibilty of creating drop-down pick
lists longer than the default limit of only 25 items? Tag: Can you use VBA to create a pie chart in Word Tag: 58199
How do I get mailing labels in Word into a sortable form?
My organization has its mailing labels typed onto sheets of labels in Word.
When we want to send out a mailing we need to sort by zip code by hand. It
is very time consuming. Is there a way we can take the info from word and
put it into an Excel or Access data base so that the labels can be sorted
before they are printed?
Thanks.
Desparate for time. Tag: Can you use VBA to create a pie chart in Word Tag: 58198
Automation of the Office "Equation Editor"
Hello
how can I make an Automation of the Office "Equation Editor". If it is
possible what interfaces does this component have?
Thanks Peter Tag: Can you use VBA to create a pie chart in Word Tag: 58197
Best way to check if doc exists?
I know there are a couple of different ways to see if a document exists
(before I throw an error trying to do something with it!), but I'm wondering
if there is a "best" way - that is, one most likely to behave nicely in just
about any routine I stick it into. The path will always be the same on any
user's computer - with their username inserted, of course - so I could use
that. I've done different things - some quite by accident - in other code:
set an object to a doc that isn't there and trap the lack of an object name;
try to open it and trap the error; and such like. I tried Exists, but that
doesn't seem to work for documents. Any suggestions?
Ed Tag: Can you use VBA to create a pie chart in Word Tag: 58190
Tables and Charts
I am using a user form which will collect data from the user.
Is there VBA code that can be used to take the data from the userform and
create a table and a pie chart?
Thanks Tag: Can you use VBA to create a pie chart in Word Tag: 58189
Run-time error '4605': This method or property is not available...
Hi,
I'm getting the following message when trying to use the selection property
in the Reviewing Pane in Word 2002:
Run-time error '4605': This method or property is not available because the
current selection is editing the reviewing pane.
All I'm doing is letting the user select from a list and trying to insert
the value such as this and I get the error when trying to execute the
'Selection.TypeText Text...' line:
'*****************
' We will go through all of the values in our current list and check
' each one to see if it has been selected. If so, we will echo the
' associated text back into the document.
For iArrValue = 0 To lstSelection.ListCount - 1
If lstSelection.Selected(iArrValue) = True Then
Selection.TypeText Text:=arrResponse(iArrValue)
End If
Next
'*****************
If I record a macro in my main document or in the Reviewing Pane, just
typing in text, the macro command is no different, using the selection
property. It records fine and I can play it in my main document but not in
the Reviewing Pane, as I'll get the error listed above.
I can also manually type in the Reviewing Pane so it appears to be accessible.
Either I am missing something or the selection property is not able to be
used within the Reviewing Pane.
Any ideas?
Bill Tag: Can you use VBA to create a pie chart in Word Tag: 58187
VB Help
Hi all,
I`m trying to create a document with a text box and 3 combobox.
Here is what I`m trying to do:
TextBox shows today`s date.
ComboBox1 shows value1 and value2
ComboBox2 shows value 3 and value4
ComboBox3 shows values 5,6,7,8
note: there is no connection between the comboboxes what so ever.
first issue: I tried to use AddItem method undre private sub
Document_Open -
ComboBox1.Additem "value1" etc...
After I save and close the document all the options from the ComboBoxes are
gone.
Second issue: I need to be "clean" when I open the document. Only the
textbox should be filled with today`s date.
I hope I`m clear here.
Thank you so much for your time,
Tom Tag: Can you use VBA to create a pie chart in Word Tag: 58185
VBA-controlled mail preparation while using Word as mail editor
In my Word VBA-application I would like to open Outlook with a partly
prepared email that the user is expected to finish before sending it.
However, this causes a problem when the user has chosen to use Word as the
mail editor. Is there a simple way to temporarily cancel and then restore
the users selection of editor?
/BosseH Tag: Can you use VBA to create a pie chart in Word Tag: 58177
Links should update when you "Save As"?
I have links of the form:
{ LINK MyClass.Image Document1 "_1159793036\\Spot 1" \a \t \* MERGEFORMAT }
(for example). The document I created to hold the links was called
"Document1". When I save the document as, say, "gianttestreport.doc" and
then reload it, Word says I have links referring to other documents in my
file. I assume its because it doesn't automatically change "Document1" in
the links to refer to the current documents new name after saving.
Is there any way around this? Tag: Can you use VBA to create a pie chart in Word Tag: 58173
XMLNodes in Headers & Footers
Hi
Iâ??m struggling to find the best way to update XMLNodes contained within a
Word document header (or footer).
I would have expected "document.SelectNodes(...)" to include nodes from the
headers and footers but it doesnt.
The only answer(ish) I've found is:
foreach (Section sect in _doc.Sections)
{
foreach (HeaderFooter headfoot in sect.Headers)
{
if (headfoot.Range.XMLNodes.Count>0)
{
// headfoot.Range.XMLNodes.SelectNodes(...)
}
}
foreach (HeaderFooter headfoot in sect.Footers)
{
if (headfoot.Range.XMLNodes.Count>0)
{
// headfoot.Range.XMLNodes.SelectNodes(...)
}
}
}
But (a) this seems a bit pants and (b) it doesnt seem to work anyway!
Does anyone know how to do this the "official" way?
Many thanks
Jonathan Tag: Can you use VBA to create a pie chart in Word Tag: 58170
Footnote Revisions refusing to go away even with code...
Sorry for cross-posting but I didn't know where else to post this and really
need the help so here goes...
I've got a VB6 app that creates Word docs utilizing mail-merge. When this
app is run on machines with Office 2000 or earlier, the docs print out fine
in "Final" view with all the revisions hidden. I use the following code to
do this:
WordApp.ActiveDocument.Revisions.AcceptAll ' WordApp is a
Word.Application Object
When this app runs on a machine with Office 2003, the docs print out with
all the revisions hidden except for the ones in the footer of the document.
I've burned two days already on this problem and am hoping to salvage today.
Does anyone know what's causing this and is there a workaround? Any help
would be appreciated.
Thanks In Advance,
Steve. Tag: Can you use VBA to create a pie chart in Word Tag: 58169
Intecepting Font & Font Size dropdowns from the 'Formatting Toolba
I am putting together a template where I want to restrict the font to Arial
and the font size from 8 to 11 point. How can I intercept the dropdowns
located on the standard 'Formatting Toolbar'?
--
Tim Shaffer Tag: Can you use VBA to create a pie chart in Word Tag: 58167
break link VBA
Dear all,
Does anybody know how I can break links (coming from excel graphics)in word
using VBA?
the following solutions did not help me:
ActiveDocument.Fields.Unlink
Sub RemoveLinks()
Dim aField As Object
For Each aField In ActiveDocument.Fields
aField.LinkFormat.BreakLink
Next aField
End Sub
thanks,
Jan Tag: Can you use VBA to create a pie chart in Word Tag: 58165
Adding a button to a Word context menu
What I want to do:
I want to add a button to the shortcut menu (context menu/rightclick menu)
that appears when a user right-clicks on a piece of text.
I want it to be compatible with word 2000 and up
I want to use Visual Basic .Net .
So far I've started to fumble around with a shared add-in for a bit, but I
have no idea if what I want is even possible nor how to do it. Can anyone
point me in the right direction here? Tag: Can you use VBA to create a pie chart in Word Tag: 58158
Adding a button to a Word context menu
What I want to do:
I want to add a button to the shortcut menu (context menu/rightclick menu)
that appears when a user right-clicks on a piece of text.
I want it to be compatible with word 2000 and up
I want to use Visual Basic .Net .
So far I've started to fumble around with a shared add-in for a bit, but I
have no idea if what I want is even possible nor how to do it. Can anyone
point me in the right direction here? Tag: Can you use VBA to create a pie chart in Word Tag: 58157
Adding a button to a Word Shortcut menu
What I want to do:
I want to add a button to the shortcut menu (context menu/rightclick menu)
that appears when a user right-clicks on a piece of text.
I want it to be compatible with word 2000 and up.
I want to use Visual Basic .Net .
So far I've started to fumble around with a shared add-in for a bit, but I
have no idea if what I want is even possible nor how to do it. Can anyone
point me in the right direction here? Tag: Can you use VBA to create a pie chart in Word Tag: 58155
Adding a button to a Word shortcut menu
What I want to do:
Add a button to the shortcut menu that appears when a user right-clicks on a
piece of text.
Compatible with Word 2000 and up
Using Visual Basic .Net
So far I've tried using a shared add-in project and tried a few things, but
I'm really stuck and don't know for sure if it's even possible what I want to
do. Can someone point me in the right direction here? Tag: Can you use VBA to create a pie chart in Word Tag: 58154
Adding a button to a Word shortcut menu
What I want to do:
Add a button to the shortcut menu that appears when a user right-clicks on a
piece of text.
Compatible with Word 2000 and up
Using Visual Basic .Net
So far I've tried using a shared add-in project and tried a few things, but
I'm really stuck and don't know for sure if it's even possible what I want to
do. Can someone point me in the right direction here? Tag: Can you use VBA to create a pie chart in Word Tag: 58153
Find.Execute not found in text boxes
I need to use the find method to search a document for a certain string. I
have found that the search does not include text boxes and I need it to.
On my PC (using Word 2000) if I create a text box and populate it with the
word 'Hello' and then use the find function, it is found in the text box.
If I use vba to find, it does not find it in the text box. Even if I record
a macro of the successful manual find, when I play the macro the find is not
found.
Can anyone shed any light on this? Tag: Can you use VBA to create a pie chart in Word Tag: 58148
Find in Text Boxes
I need to use the find method to search a document for a certain string. I
have found that the search does not include text boxes and I need it to.
On my PC (using Word 2000) if I create a text box and populate it with the
word 'Hello' and then use the find function, it is found in the text box.
If I use vba to find, it does not find it in the text box. Even if I record
a macro of the successful manual find, when I play the macro the find is not
found.
Can anyone shed any light on this? Tag: Can you use VBA to create a pie chart in Word Tag: 58147
Can't access second excel addins after executing first in word.
The word macro contains few lines as:
CopySMS.Application.Run ("labgraph.xla! _
Shrink.ParallelShrink") 'makes a excel plot and copies
Selection.PasteSpecial Link:=False, _ DataType:=wdPasteOLEObject, _
Placement:=wdInLine, DisplayAsIcon:=False
Selection.MoveDown Unit:=wdLine, Count:=2
CopySMS.Application.Run ("labgraph.xla!xlMain.CloseWorkbook")
The problem is that it doesn't run the second addins and stops over there.
But, if paste command is commented, it runs it. Somehow, this paste command
is stopping the second addins to run.
If anybody can help in this please.
Thanks,
Kislay Tag: Can you use VBA to create a pie chart in Word Tag: 58141
Events with Application Object
Word 2003
The &%*$&*% Help files!
I am trying to use events with the Application object. The Help page entitled
"Using Events with the Application Object" has the following as the last step:
***************
Initialize the Declared Object
Before the procedure will run, you must connect the declared object in the
class module (App in this example) with the Application object. You can do this
with the following code from any module.
Dim X As New EventClassModule
Sub Register_Event_Handler()
Set X.App = Word.Application
End Sub
Run the Register_Event_Handler procedure. After the procedure is run, the App
object in the class module points to the Microsoft Word Application object, and
the event procedures in the class module will run when the events occur.
**************
I copied the above code into an ordinary module.
1. First of all, where do you really put the Dim statement? If you copy/paste
the code as is, the Dim statement ends up above the dividing line, directly
below the "End Sub" line of the previous procedure. This results in a Compile
error.
2. To get things moving, I moved the Dim statement below the "Sub
Register_Event_Handler()" line (i.e to the second line of the code). This
results in the following error: "User-defined type not defined." (For your
reference, the Help page that this leads to is reproduced below.)
MY QUESTION: What steps do I need to take to resolve this error? Which (if
any) of the three choices on the Help page, below, is most appropriate?
Thanks very much.
Jay
**********Help page*************************
User-defined type not defined
You can create your own data types in Visual Basic, but they must be defined
first in a Type...End Type statement or in a properly registered object library
or type library. This error has the following causes and solutions:
- You tried to declare a variable or argument with an undefined data type or
you specified an unknown class or object name.
Use the Type statement in a module to define a new data type. If you are trying
to create a reference to a class, the class must be visible to the project. If
you are referring to a class in your program, you must have a class module of
the specified name in your project. Check the spelling of the type name or name
of the object.
- The type you want to declare is in another module but has been declared
Private.
Move the definition of the type to a standard module where it can be Public.
- The type is a valid type, but the object library or type library in which it
is defined isn't registered in Visual Basic.
Display the References dialog box, and then select the appropriate object
library or type library. For example, if you don't check the Data Access Object
in the References dialog box, types like Database, Recordset, and TableDef
aren't recognized and references to them in code cause this error.
************************ Tag: Can you use VBA to create a pie chart in Word Tag: 58138
How to delete from first page to start of the next section break
Hi There,
Would you please let me know how to delete from first page until the first
section Break (Next page) in VBA?
Any help would be great.
Thanks, Tag: Can you use VBA to create a pie chart in Word Tag: 58137
Find/Replace only supports alphabetic characters?
I'm trying to do a find/replace by automating Word from a C# application.
It works fine as long as my find/replace text is alphabetic. If I try to do
a find/replace using a string such as "C#", I get an error: "The Find What
text for a Find All Word Forms search can only contain alphabetic letters.".
I tried enclosing the string in quotes, but that doesn't work either. That
actually will cause the problem with text that otherwise works - it doesn't
like the quotes either.
Here's my code (this code highlights all instances of "text" in red/bold):
Object oReplaceAll =
Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
Object oText = text;
Object oReplaceText = text;
wordDoc.Select();
msWord.Selection.Find.Text = oText.ToString();
msWord.Selection.Find.Replacement.Text = oReplaceText.ToString();
msWord.Selection.Find.Replacement.Font.Bold = 1;
msWord.Selection.Find.Replacement.Font.Color =
Microsoft.Office.Interop.Word.WdColor.wdColorRed;
msWord.Selection.Find.Execute(ref oText, ref oFalse, ref oFalse, ref
oFalse, ref oFalse, ref oTrue, ref oTrue, ref oFalse, ref oTrue, ref
oReplaceText, ref oReplaceAll, ref oMissing, ref oMissing, ref oMissing, ref
oMissing);
You can do what I want from within word itself - how do you call
find/replace and allow non-alphabetic characters?
- Dave Tag: Can you use VBA to create a pie chart in Word Tag: 58132
Is VBA/Word slow...or is it just the way I did it?
I have created what I believe to be a rather complex document/program in word
(I believe there are over 13000 total lines of code). I have quite a few
auto-text entries that either are, or contain graphics. The overall size of
my Word Template (one I created specifically for this purpose, not
Normal.doc) is quite close to 8 Megs. The document doesn't seem like it
takes excessivly long to open, or for the first UserForm to appear as a
reault of the AutoNew Macro which calls the form. It seems like it takes
excessively long for 1) items to be transferred from the userform comboboxes
and text boxes to the FormFields in the template, 2) the userForm to unload,
and 3) the 2nd userform to load. Then it seems to take excessively long for
the same things to occur with the 2nd userform. Tag: Can you use VBA to create a pie chart in Word Tag: 58131
Template Macro to Save Documents
Iâ??m recording a macro, within a template, that will save the values of the
bookmarks as part of the file names. While Iâ??m recording I get the save as
dialog box to show but the file type says template.dot. I donâ??t want to save
the template file, .dot, within my macro, I want the .doc file to be saved.
If I change the file type to .doc and change the file location, away from
the template subdirectoy, the macro disappears when I go to reopen the
template. Word doesnâ??t allow me to stop the macro when the SaveAs dialog box
is open. Pressing the cancel button in the SaveAs dialog box, records the
cancel within the macro. (Iâ??m also recording encryption in the Save As box
but that seems to work fine.)
How can I save the macro in the template and still save the file as a
document? (Leaving the Save As dialog box open with the proper file location
and file name where all the user has to do is press Save is great?)
Thanks,
Phil Tag: Can you use VBA to create a pie chart in Word Tag: 58129
Adding shapes...
How can I add a shape at the current cursor position using VBA? I would
like to add a small rectangular box. Is this possible?
Thanks Tag: Can you use VBA to create a pie chart in Word Tag: 58124
PrivateProfileString Long Key Values
I recently read several postings on how to create a GetINISetting function
that would replace the System.PrivateProfileSetting function, which is
limited to 255 characters. The function shown retrieved a long string value,
which helped me out a lot. How can this be modified to 1) write to the INI
file to append a new INI Key value that is longer than 255 characters or
replace an existing INI Key value with a new value, that is longer than 255
characters?
The original function was...
Function getIniString(file As String, section As String, key As String)
Dim nr As Long
Dim curLine As String
nr = FreeFile
Open file For Input As nr
' read until section is found
Do Until EOF(nr) Or LCase(curLine) = "[" & LCase(section) & "]"
Line Input #nr, curLine
Loop
' read until end of file or key is found
Do Until EOF(nr)
Line Input #nr, curLine
' key found?
If LCase(curLine) Like LCase(key) & "=*" Then
' yes -> outta here
getIniString = Mid(curLine, Len(key) + 2)
Exit Do
End If
Loop
Close nr
End Function
Thanks in advance for your help. Tag: Can you use VBA to create a pie chart in Word Tag: 58123
Re: FileSystemWatcher getting Word temp file
From: "zfeld" <zfeld100@hotmail.com>
Subject: Re: FileSystemWatcher getting Word temp file
Date: Tuesday, October 19, 2004 12:29 PM
Thanks,
What I discovered is that the temporary ~$documentName.doc never gets
renamed, it is just deleted on close. However another file is created at the
same time as the ~$documentName.doc that doesn't even have the .doc
extension, which was why I wasn't seeing it, it is usually something like
wrd005.tmp this then gets subsequently renamed into MyDocument.doc. I
therefore had to ignore the creates of .doc files that start with ~ and
catch renames from a .tmp extension to .doc extensions.
"Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> wrote in
message news:1m8bffq8zpl5x$.pwpz8yof3ekv$.dlg@40tude.net...
> On Mon, 18 Oct 2004 11:20:56 -0400, zfeld wrote:
>
>> My app is creating a word document which my app calls saveas() and saves
>> it
>> to a given directory that is being watched by a fileSystemWatcher. The
>> problem is that the fileSystemEventHandler for creation is only called
>> for
>> the temporary filed created by word which shows up as ~$documentName.doc
>> the
>> real file named MyDocument.doc will never invoke the
>> fileSystemEventHandler
>> for creation. Now when the user closes Word the temporary file is deleted
>> and my app only had a handle to that file.
>> How come I am not getting any notification about the creation of the real
>> file even though it was saved using saveas() and I do see it created in
>> windows explorer?
>
> Off the top of my head, I would say that the temp file is being created
> and
> then renamed to the final filename. When a file is renamed, a create is
> not fired for the new name. Try setting up your FileSystemWatcher to
> handle the rename event.
>
> --
> Chris
>
> dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
>
> To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
> replace certain words in my E-Mail address. Tag: Can you use VBA to create a pie chart in Word Tag: 58121
fill in a new field using data from a field already filled out in.
I have a contract that has multiple fields. This contract is protected and
given to reps to fill out. They have to fill in the customer name several
places in the document, and I would like for them to be able to fill it in
once, and have the rest automatically fill in. How can this be done? Tag: Can you use VBA to create a pie chart in Word Tag: 58119
I have a Word table that gets populated with figures.
Is there VBA code that I can write that automatically creates a pie chart
when data is entered into the table.
Thanks