Finding bad formatting
Dear people,
For some time now, I'm struggling to solve a VBA problem.
Some of you already gave some assistance, for which I'm great full.
I'm trying to find some bad formatting in a word document using VBA.
On all paragraphs are paragraph styles applied. On pieces of some
paragraphs, are Character styles applied. On other pieces of text, other
manual formatting is applied like "bold" or "Bold Italic".
I'm trying to detect the pieces of text that has no "character style"
applied and yet have other manual formatting is applied like "Bold Italic".
For example:
Some text is set to bold, this is wrong.
Other text has the character style "BOLD" applied, this is good.
I need to highlight all the bad formatting.
Can anyone please help me?
Thanks
JD Tag: change Tag: 62495
disable some shortcut key's
Hi
Does anyone know how to disable some shortcut key's like ...
CTRL + F3
CTRL + SHIFT + F3
CTRL + "2"
Thanx
JD Tag: change Tag: 62494
msmapi32.ocx vba vb problem
I made a mail application in word vba. It works fine but I didn't know that
someone installed vb 6 on my computer. Other people want to use the
application too and the activeX control: MSMAPI32.OCX is missing. Can I put
that ocx on a network drive. Those people dont have administrator rights and
can't install applications, only NAL-objects. A solution is making an exe
with the vb 6 wizard but to install that you must have rights to do that.
Does anyone know a solution. Put it in c:\windows\system32 or run a register
program in vbs code or something?
If I place the ocx on a drive on a user computer and click the microsoft
MAPI controls in the toolbox and choose the directory with the ocx it works
so it has not to bee registered or licensed, am I right??? CDO doens't work
it hits the firewall...
Thanks, Siebe Tag: change Tag: 62491
disable toolbar buttons
Hi everyone,
Does anyone know how to disable some toolbar buttons (so they apprear to be
gray) using vba ?
For example ..
the italic-, bold- and underline-buttons
the font-popup in the toolbaar...
Thanx
JD Tag: change Tag: 62486
Deleting a page forcibly
Hi,
I want to delete a particular *real page*.
Like many times if I copy data from let's say Web/ some software etc and
paste in to Word (I use word for Printing only !!!) then the last page would
be having no data (atleast it would be blank as far as am able to see) but
still even if am sitting on the period after the last letter in the Main
Story and if i keep pressing delete the Last page just wouldnt get deleted.
Why does this happen?
Is there a VBA solution to it (and yes, would be happy to know non-VBA
solution as well)
Thanks a lot,
Hari
India Tag: change Tag: 62475
Find string in table and move to next cell
Hello All
Windows 2K
Word 2K
I'm trying to locate a string (strFWitnessName) in a table in my document
and then move one cell to the right to enter a page number.
strFWitnessName could appear in 1 of three tables in the document ( but it
will never appear in all three)
I do not want to search the entire document as strFWitnessName will appear
throughout the document text as well.
I found the following code posted by Doug Robbins and tried testing it but
apparently I am just not familiar enough with vba to understand what it is
doing.
Dim i As Integer, j As Integer, myrange As Range
For j = 1 To ActiveDocument.Tables.Count
For i = 1 To ActiveDocument.Tables(j).Rows.Count
Set myrange = ActiveDocument.Tables(j).Cell(i, 1).Range
myrange.End = myrange.End - 1
If myrange.Text = strFWitnessName Then
ActiveDocument.Tables(j).Cell(i, 2).Range.Text = "pagenumber1"
ActiveDocument.Tables(j).Cell(i, 3).Range.Text = "pagenumber2"
End If
Next i
Next j
Any help would be greatly appreciated.
TIA
Debra Tag: change Tag: 62470
Special character not recognized
ActiveDocument.Bookmark("mybookmark").Range.InsertAfter "text"
where texts are texts that has special character created through
Insert>Symbol>ShortcutKey method.
How do I get around this problem? Tag: change Tag: 62469
AddressLayout
I was attempting to eliminate the United States of America for addresses
when I import an address from Outlook. Somehow in the process "United States
of America" got substituted for the zip code. No matter where I place the
{<PR_POSTAL_CODE>} in the address form, it comes out "United States of
America" I assume there is a table somewhere that sets forth those codes.
Any ideas.
Nick@nicksigur.com Tag: change Tag: 62467
automatically close a doc after user clicks on email send?
Hi All
I have a word form ready with the email header active in the document. When
I select Send on the email, the document remains open. I would like it
automatically close once the send button is hit. I found that the
ActiveWindow.EnvelopeVisible toggles the word email header.
I have got this far via the web but I really have no idea:
created a Class Module -clsobject:
Public WithEvents oApp As Word.Application
Private Sub oApp_DocumentChange()
' dunno what to put here
End Sub
created a module:
Dim oAppClass As New clsObject
Public Sub AutoExec()
Set oAppClass.oApp = Word.Application
If ActiveWindow.EnvelopeVisible = False Then
ActiveDocument.Close
End If
End Sub
Any ideas? Thanks in advance Tag: change Tag: 62456
SetFocus on a userform Does Not Work
I have a fairly simple userform with a frame and two
textboxes inside the frame. If a user makes an invalid
entry I want to display a message, clear the entry, and
set the focus back to the same field.
The mesgbox displays perfectly, and the entry is cleared
fine. However, the focus keeps going to the next textbox
in the frame. I am getting frustrated! I even tried
setting the focus back to the frame first, and then to the
field. I also tried using the Exit event with no success.
I am using the AfterUpdate event and the name of my
textbox is txtClientNumber. My code appears below.
Any ideas would be apprecaited. Thanks so much in advance.
Private Sub txtClientNumber_AfterUpdate()
Dim StrClientName As String
Dim rstClientName As ADODB.Recordset
Set rstClientName = New ADODB.Recordset
StrClientName = "SELECT client_name FROM hbm_client
WHERE client_code = '" & txtClientNumber.Value & "'"
rstClientName.Open StrClientName, Main.cnn
If rstClientName.EOF = True Then
MsgBox "That is an Invalid Client Number"
txtClientNumber.Value = Null
frmMain.fme1.SetFocus
txtClientNumber.SetFocus '***PROBLEM HERE
Else
rstClientName.MoveFirst
txtClientName.Value = rstClientName
("client_name").Value
End If
End Sub Tag: change Tag: 62453
Printing pictures in Word
if i insert a picture at say 12cm x 12 cm, word prints it at around 10.5cm x
10.5cm
It looks like the page is set up smaller than it should be, but its set up
for A4
Help please
Thanks in advance, Snaff Tag: change Tag: 62452
Can't add a reference to the specified file
Here's one for the Google archive, in case anyone else hits it.
On my development machine, I began getting an error when attempting to
set a reference within a Word VBA module to another Word template. The
error was:
Can't add a reference to the specified file
The template I was trying to set a reference to was one I have been
using for over a year without a problem. My machine gets pretty badly
beaten up while I'm coding and debugging, so no doubt I fried
something. Now here's the strange thing. The template to be referenced
was:
c:\My Programs\Foo\Foo.dot
The precise symptom: start word, hit Alt+F11, open a module, choose
Tools, References, navigate to and select the Foo template. PRANG!
Error.
Exit Word. Rename either the template *or* the folder *or* the folder's
parent, and everything works! E.g.:
c:\My Programs\Foo\FooA.dot -- no problem
c:\My Programs\FooZ\Foo.dot -- no problem
It was only when the template full path was
c:\My Programs\Foo\Foo.dot
that the error occurred. Very bizarre!
I reinstalled MS Office, cleaned the registry of all references to Foo,
but no joy.
It turned out that the problem was somewhere inside my XP profile. When
I logged in as another user, everything worked. I simply renamed my old
profile, then logged in as myself again. Presto! Problem solved. (I had
to harvest my favorites, Start menu, etc. from my old profile, but it
sure beat nuking and rebuilding the machine.
Hope this helps someone else. Tag: change Tag: 62448
How do I get data from MySQL ?
Is there a way to get data from a MySQL database? Then can I insert the data
into Word in some non-table format? I want to be able to place some data
within paragraphs of my document. Tag: change Tag: 62447
Calculating in VBA
This expression tells me which page I'm on:
Selection.Information(wdActiveEndPageNumber)
I want to do something if a page is odd or something different if it
is an even number.
Is there a way of doing this in VBA, please?
I was looking for something that would allow me to divide a page
number by 2. If the remainder was not zero then it must be an odd
number. That's my logic but I cannot work that in VBA.
Regards
Roderick O'Regan Tag: change Tag: 62442
Unable to insert word html file into a Word document
Hello,
I have a HTML document created by saving the document with Word using the
wdFormatHLMLFiltered. This works fine and I can see the document. However,
if I attempt to insert this HTML file into another word document I only see
the first line of the document. Is there some sort of restriction from
using wdFormatHTLFiltered and other word documents?
Thanks,
Jerry Tag: change Tag: 62441
What is wrong with this code?
Hello,
I´m trying to paste two cells (text) from Excel to Word. The code pasted
below does not completely do the trick - please could someone tell me what
is the problem, what must be added?
Problems:
1. If I leave out the ".Collapse wdCollapseEnd", the range A1:D1 gets
replaced by the range A2:A6. Then the range A2:A6 is formatted like I want
it to be (bold).
2. If I dont leave it out, the formatting is not correct, but both ranges
are being copied otherwise correctly. Then the range A2:A6 is not being
formatted at all, but copies the formatting from range A1:D1 (not bold).
Sub TW()
Dim AppWD As Word.Application
Dim DocWD As Word.Document
Dim RangeWD As Word.Range
Set AppWD = CreateObject("Word.Application.10")
AppWD.Visible = True
Set DocWD = AppWD.Documents.Add
With DocWD
Set RangeWD = .Range
Sheets("T").Select
Range("A1:D1").Select
Selection.Copy
With RangeWD
.Font.Name = "Arial"
.Font.Size = 12
.Font.Bold = False
.PasteAndFormat Type:=wdFormatPlainText
.Collapse wdCollapseEnd
Sheets("T").Select
Range("A2:A6").Select
Selection.Copy
With RangeWD
.Font.Name = "Arial"
.Font.Size = 12
.Font.Bold = True
.PasteAndFormat Type:=wdFormatPlainText
.Collapse wdCollapseEnd
End With
End With
End With
End Sub Tag: change Tag: 62439
Word Templates
Can word templates be lock down or controlled? What we are looking for is
locking down the template and let users change content of the templates.
Also, if the template changes, then what happens to the old content? Tag: change Tag: 62432
Automating mailmerge from VB ActiveX control.
Hi,
I'm having a problem executing a word mailmerge automated by an ActiveX
control embedded in an intranet web page.
I have an intranet application which allows users to upload word
mailmerge main documents, and then have other users of the intranet
execute mailmerges with data in our intranet database.
It all works a treat except when one of my users uploads a mailmerge
main document which has been created using an edited normal.dot. In
these cases word opens an Open Header Source dialog box. I can then
select any word document I like, and the mailmerge completes successfully.
It is the Open Header Source dialog which I want to prevent - as it will
certainly confuse some of my less savvy users.
If that same mailmerge main document is used on the machine that created
it, it works fine, without the extra dialog.
My code, for this part of the system, for what it's worth is:
'------------------------------------------------------------
Set objMSWordInstance = New Word.Application
' using the new word application ...
With objMSWordInstance
' make word visible
.Visible = True
' activate word applciation
.Activate
' create new instance of word document
Set objDummyDocument = objMSWordInstance.Documents.add()
' close the dummy document
objDummyDocument.Close (wdDoNotSaveChanges)
' create new instance of word document using the saved mailmerge
template
Set objSourceDocument = .Documents.Open(strMailmergeTemplateFilename)
' create new instance of Word mailmerge object
Set objMailMerge = objSourceDocument.MailMerge
' using the new mailmerge object ...
With objMailMerge
.OpenHeaderSource strHeaderRecordFilename, wdOpenFormatText,
False, True
' use the temporary file we've just created as the word
mailmerge data source
.OpenDataSource strFieldValuesTempFilename, wdOpenFormatText,
False, True
' set the last record property of the data source
' (this means that the blank record we stuck on the end
' of the data records will not be displayed)
.DataSource.LastRecord = intTotalRealRecords + 1
' execute the mailmerge!
.Execute (True)
End With
' dereference mail merge object
Set objMailMerge = Nothing
' close the original source document (discarding changes)
objSourceDocument.Close (wdDoNotSaveChanges)
' dereference word document object
Set objSourceDocument = Nothing
End With
' ---------------------------------------------------------
Debugging has told me that it is the .OpenHeaderSource command which is
causing the dialog to open.
In the above code the strHeaderRecordFilename variable is the path &
filename of a text document which holds the merge field names. The data
records are held in a text file for which the strFieldValuesTempFilename
variable holds the path & filename.
Does anyone have any suggestions?
Matt Tag: change Tag: 62430
Syntax Blues - A repost
Hi,
I messed up in explaining my requirement in my previous post ("text
replacing based on a true condition") in
the --microsoft.public.word.vba.beginners -- hence rewording the same here.
(am not conversant with word other than manual formatting and using it as a
Scratch application. I work primarily with Excel)
a) Whats' the syntax for programmatically knowing the actual page number of
a document. Like if the cursor is in page 65 , I should be able to get the
value 65.
I tried the following
Msgbox activedocument.selection.pagenumber
but getting a Run-time error "438" - object doesnt support this property or
method.
b) Whats the syntax for programmatically looping through each sheet in the
document. Like I can write the following
For I = 1 to NoOfPagesInTheDocument
But, how would I find the value of NoOfPagesInTheDocument.
Basically I want the value for total no of pages in that document. This
value also gets displayed in the Word taskbar/information area in the
bottom. Like where it says 45/750, which means am at the 45th page and 750
is the NoOfPagesInTheDocument.
c) Whats the syntax for restricting the Search/Find/replace Feature to a
particular page only. Like , if am in a For Loop as described in b) and if I
want to restrict my find/replace only to the present page, then how do I do
it?
Please guide me.
Thanks a lot,
Hari
India Tag: change Tag: 62423
Cut and paste to new document
Hi,
I have code that actually find the 1st 'S' of the document where it will
cut and paste to new document. Can i coded in vb that it will find the next
'S' and vut and paste instead.
With Selection.Find
.Execute FindText:="<[FS]????????>", MatchWildcards:=True,
MatchWholeWord:=True, Wrap:=wdFindContinue, Forward:=True
'MsgBox "!"
'Invoke the SaveAs box
With Dialogs(wdDialogFileSaveAs)
.Name = Trim$(Selection.Text)
.Show
End With
End With
regards,
ben Tag: change Tag: 62422
Another tagging question
The complexity of this task got my attention. Let me explain as best I can:
Problem / Input:
1. djskljfdslkfjdsf
2.. sadaskdsa
3.. dsadsadsa
1.. fsdfdsf
2.. dfdsfds
3.. dfdsfds
4.. djasda
Desired Output:
<LISTGROUP>
<LISTITEM>
<NUMBER>1.</NUMBER> <TEXT>djskljfdslkfjdsf</TEXT>
</LISTITEM>
<LISTITEM>
<NUMBER>2.</NUMBER> <TEXT>sadaskdsa</TEXT>
</LISTITEM>
<LISTITEM>
<NUMBER>3.</NUMBER> <TEXT>dsadsadsa</TEXT>
<LISTITEM>
<NUMBER>a.</NUMBER> <TEXT>fsdfdsf</TEXT>
</LISTITEM>
<LISTITEM>
<NUMBER>b.</NUMBER> <TEXT>dfdsfds</TEXT>
</LISTITEM>
<LISTITEM>
<NUMBER>c.</NUMBER> <TEXT>dfdsfds</TEXT>
</LISTITEM>
</LISTITEM>
<LISTITEM>
<NUMBER>4.</NUMBER> <TEXT>djasda</TEXT>
</LISTITEM>
</LISTGROUP>
Notice how each individual item is encapsulated in a <LISTITEM> tag and how
one level (3a, 3b, 3c) are encapsulated under 3's LISTITEM tag. Well, this
is hard to explain but I hope you can see the logic.
Now, there could be upto 4 such levels (i.e) 3.a may have a 3.a.i which may
further have a 3.a.i.A and so on. The taggings need to be done
appropriately. Also, the numbers may either be typed or could be part of the
automatic bullet lists that Word has. Also, if manual spaces are used
instead of bullet lists, they are usually of the right number. I mean,
1. dasdas
a. dssffsd
b. sadajkjs
c. dfskjs
is also possible (spaces usually have a + or - 2 error rate)
Questions:
1) Any idea on how I should go about doing this in the most error-free
fashion? We get many documents to process and the most error-free method is
desirable.
Before I begin coding this, I thought I would see if any one had any special
tips I should take into consideration.
Thank you for your time/ response.
Vince Tag: change Tag: 62421
Save doc as Webpage but cannot view in browser at the same time
I am writing the following code, it will popup a save as dialog, when I got the path and name info, i run ActiveDocument.SaveAs to save doc as webpage. After that, I tried to call ActiveDocument.FollowHyperlink to open that webpage, however, nothing happen.
But then, i tried to call ActiveDocument.FollowHyperlink to open a file which is saved before, it works fine.
I feel strange that if i just saved the file, i can't immediately call ActiveDocument.FollowHyperlink to view the page. Anyone can help?
Dim Path, Name, fullPath As String
With Dialogs(wdDialogFileSaveAs)
If .Display Then
Path = WordBasic.FileNameInfo(.Name, 5)
Name = WordBasic.FileNameInfo(.Name, 4)
fullPath = Path & Name & ".html"
ActiveDocument.SaveAs FileName:=fullPath , FileFormat:=wdFormatHTML, _
LockComments:=False, Password:="", AddToRecentFiles:=False, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
ActiveDocument.FollowHyperlink fullPath
End If
End With
--
Message posted via http://www.officekb.com Tag: change Tag: 62420
One issue about the GetCommandBars
Hello,
I am writing a program based on COM&Office word.
The codes are:
.......
_Application m_app;
COleException e;
m_app.CreateDispatch("Word.Application.8", &e);
....
Now, I want to get the CommandBars. So, I do like this:
........
LPDISPATCH lpdisp_comBar = m_app.GetCommandBars();
........
My question is:
How to get the object of 'CommandBars' from the 'lpdisp_comBar'?
I don't know WHICH CLASS represent the object 'CommandBars'.
If somebody know how to do it, please tell me.
Thanks a lot.
--
Message posted via http://www.officekb.com Tag: change Tag: 62418
Creating Template with drop-down boxes
I need to create a Template in Word for multiple users. It needs to have
drop-down boxes with fill-in choices to select from a list. I know Word can
do this, but I don't know to begin. I don't understand the instructions given
because they include locating an already-created Template with drop-down
boxes and I can't find one.
HELP!! Tag: change Tag: 62416
how to select range of text to delete?
Given a document with the following text:
The quick brown fox jumped high.
There is a cat over the lazy dog.
The quick brown fox jumped.
There is a bird over the lazy dog.
How can I write a macro to delete the text between â??jumpedâ?? and â??overâ?? so
the document ends up like:
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The following macro finds the end of â??jumpedâ??:
Sub FindFoxyJump()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "jumped"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub
Specifically how can one begin a selection from that location, and extend it
to the beginning of â??overâ??? While it is simple to select text by moving the
cursor with
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
There seems to be no such Extend:=wdExtend argument for
Selection.Find.Execute.
Please help. I am really stuck.
--
Regards,
-Ron Tag: change Tag: 62401
Replacing (removing) numbers from beginning of line (Word 2000/Windows)
Hello All,
I'm slowly but surely gaining an education into at least the basics of
writing macros. I've got something that is pretty close to what I want,
but not quite there.
I've got a bunch of documents that have step numbers manually entered.
These steps should always be in one of four styles. So I put together a
macro that looks at the style and then searches for wildcard text that
should related to the step numbers and the following tab, and replaces
them with nothing.
It mostly worked, but would occasionally delete some other text that I
didn't want to delete in some of the lines.
Now I know the step numbers are always the first thing on a line, so I
added a paragraph mark to my wildcard text string. I figured that would
ensure it would only look for the numbers that follow a return.
However, when I added the paragraph mark to the .Text and
.ReplacementText entries, my macro gets stuck in a loop between "Do
While . . ." and "Loop". Entries.
Am I going about this the wrong way, or am I just making an ignorant
mistake?
Any help will be greatly appreciated!
Dan
---
Sub MacroName()
Dim FindStyle As Variant, k As Integer
FindStyle = Array("Para 1.1", "Para 1.1.1", "Para 1.1.1.1", "Para
1.1.1.1.1")
On Error Resume Next
For k = 0 To 3
With ActiveDocument.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^p[1-9].*[1-9]^t"
.Replacement.Text = "^p"
.Format = True
.MatchWildcards = True
.Style = FindStyle(k)
Do While .Execute(Replace:=wdReplaceAll)
Loop
End With
Next
End Sub Tag: change Tag: 62396
How do I select from insertion point to search result
In my Word document, I am trying to write VBA code to select all of the text
from the current cursor position to the previous Hard Page Break.
I don't see that there is a way to get the Find method to extend the
selection from the current location to the result of the search, but I am
sure there must be some way to do a similar thing.
Can anyone show a code example to me that would accomplish this purpose,
please.
Thank you in advance. Tag: change Tag: 62392
Encapsulation - Using Word On The Server
I am going to use Word on the Server. I am aware of all the implications to
this, but I am only using Word for printing. There does not seem to be any
tool yet to print Word documents without the loading of Word. I am using Dot
Net to talk to Word. Does anybody have recommendations for the best way to
encapsulate Word? Should I simply load another dll that then calls Word, so
my main application does not go down? Any pointers in the right direction
would be appreciated.
Also, is there a way to force Word to GPF so I can test this out to make
sure the calling program recovers? I assume calling an API wrong might do
this.
Derek Hart
derekmhart@yahoo.com Tag: change Tag: 62391
Word 2000 Launched from ACT! 2005
Greetings,
We have just upgraded to the newest version of ACT!, from Best Software.
Part of the functionality of ACT! is to allow for the use of Microsoft Word
(Word 2000, which is included in Office Premier, with the latest upgrades
from the Office website) as your preferred word processor. You are able to
launch Word from with ACT!, generate documents, and then print, email, etc.
In our work, we have a printer that has two paper trays, one for plain paper
and one for letterhead. When we open and attempt to print a document in
Word, through ACT!, we are unable to use File/Print/Printer Properties to
change paper sources (tray 1 vs. tray 2). ACT! technical support is claiming
that when a session of Word is launched from another application,
functionality, in general, is limited, and specifically this function is
limited. They also claim that, as this is a limitation of Word, they have no
control over a fix.
So, my questions are;
1. When Word is launched in this fashion, is its' functionality limited?
2. If this is a limitation of Word, is it specific to Word 2000?
3. If it is not a limitation of Word at all, what can be done to "motivate"
Best Software to correct it?
All comments/suggestions/questions are welcome and appreciated.
Cordially,
Scott Taylor Tag: change Tag: 62390
How to tell if using MS Works Suite version of Word
Hi,
I have an application that uses Word VBA and gets
distributed to my users as a template, and all is well ...
... except for some users who have the MSWorks Suite
version of Word installed which seems to be slightly
different to the version of Word that comes with the real
MS Office bundle.
I was wondering whether anyone knew of a way I can tell
the difference between these 2 versions of word so that I
can prompt my users to install the full version?
Both seem to get installed to an Office folder in program
files, is there a registry key, a build number, a file
location? That distinguishes the 2 from each other?
Any help appreciated. Tag: change Tag: 62387
On which page is textbox?
Hi,
I'm using the following code to process textboxes in a document:
For Each Boxt In TDoc.Shapes
With Boxt.TextFrame
If .HasText Then
' Some processing
End If
End With
Next
Now I need the number of the page on which the current textbox
resides.
How do I determine that pagenumber?
TIA!
Bart Tag: change Tag: 62379
Bookmark
What is wrong with this? What is the proper syntax for inserting text into
the bookmark?
Private Sub OptionButton1_Click()
ActiveDocument.Bookmarks(Cholesterol).Range.InsertAfter "your cholesterol is
fine."
End Sub Tag: change Tag: 62377
Automation error with Clearformatting method????????
I suddenly have encountered a problem using the Clearformatting method via
a Word object in a VB 6 DLL.
So, I tried to reproduce the behavior within Word itself, and was able to do
so.
The first sub below results in an error, the second does not.
Can anybody reproduce this problem?
In which version of Word?
Option Explicit
Private Sub TestClearFormattingAutomation()
Dim x As Word.Application
Set x = New Word.Application
With x
.Documents.Add
With .ActiveDocument.Content.Find
On Error Resume Next
.ClearFormatting
Debug.Print Err.Number, Err.Description
Err.Clear
End With
.ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End With
x.quit
set x = nothing
End Sub
Private Sub TestClearFormattingNoAutomation()
With Application
.Documents.Add
With .ActiveDocument.Content.Find
On Error Resume Next
.ClearFormatting
Debug.Print Err.Number, Err.Description
Err.Clear
End With
.ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End With
End Sub Tag: change Tag: 62376
Do not print command button
I'm using Word 2003. I have a document with a command button. When I print
the document the command button is printes as well.
In Excel the Command Button object has an attribute called PrintObject, but
this attribute do not exist for Command Buttons in Word.
In Word 2002 I could avoid printing the Command Button by specifying under
Tools - Settings - Print that Drawing Obejcts should not be printed, but in
2003 the buttons are printed even if I do specify that drawing objects
shalll not be printed.
How do I avoid printing the Comand Button?
Jan Tag: change Tag: 62375
To handle all events in Send To Menu Item
Hello All,
I am willing to handle all the items in Send To Menu Item like Mail
Recipient, Fax Recipient, etc. Can you please guide me how to go about it.
GS Tag: change Tag: 62367
ActiveX Controls Question
I tried to use the ActiveX Calendar control but was unhappy with the behavior
(in that the calendar isn't 'collapsed' before selecting and takes up too
much real-estate). The question: Is there a way to customize ActiveX
controls; More importantly, where can I find documentation on them? Thanks. Tag: change Tag: 62365
accessing userform via menu item
I have a template which I am trying to allow the user to access a userform in
at will. I have placed a menu with specific options for the template on the
menu bar, but I'm struggling to access this userform by placing it as an
option on the customized menu.
Any help would be greatly appreciated!!!
Thanks
SRD Tag: change Tag: 62364
Generating New Doc Based on Populated Fields
Hi,
I have a project that I want to tackle efficiently.
I've created a document for customer service reps to use when interacting
with cutsomers. The document has fields for customer responses.
Here's my question:
Is there a way to then automatically generate a new document comprised ONLY
of the fields and questions that the customer responded to. In other words,
if the customer did not respond to certain questions, th enew automatically
generated file would not include that text.
Should I use the "Merge" function? Should I use VBA?
Look forward to suggestions!
Thanks Tag: change Tag: 62362
Generating New Document Based on Populated Fields
Hi,
I have a project and I want to make sure I tackle it in the most efficient
and intelligent way possible.
Essentially, I need to create a Customer Service script whit a set of q Tag: change Tag: 62361
arithmetic mistakes
I have just debugged various errors in a program for Word as due to VBA's
apparent inability to perform simple arithmetic. A simple piece of code such
as:
Dim s As Single
s = 0.05
For i = 1 To 240
s = s + 0.1
MsgBox s
Next i
produces errors on about a third the numbers generated (and the number type
seems to make no difference - same with Double, anyway).
What is going on? Tag: change Tag: 62358
Macro to Disable Macros
I have "AutoOpen" Sub in Document XYZ and in end of that sub I kill word
("Application.Quit").
I would like to have document ABC open Document XYZ and do stuff, but in
order for doc XYZ to stay open I'll have to disable the macro. How can I
programmatically open another document with macros disabled?
Thanks in advance,
Craig. Tag: change Tag: 62345
Problems with a right tab stop immediatly followed by a left tab stop.
Hey!
I need to write some right justified text immediately followed by some left
justified text (not confused with some centered text).
Am I right when I say, that it isn't possible to place two tab stops nearer
each other than 2 points?
If I run the following piece of code with x = 1, the 2nd tab stop is
overwriting the 1st tab stop.
But if x = 2 the code produces 2 tab stops.
How can I place the 2 tab stops as near as possible?
Ebbe
---------------------------------------------------------------------------------
Sub TabTest()
Dim TabPosition As Long
Dim x As Long
TabPosition = 200
x = 1
Selection.ParagraphFormat.TabStops.ClearAll
Selection.ParagraphFormat.TabStops.Add _
Position:=TabPosition, _
Alignment:=wdAlignTabRight, _
Leader:=wdTabLeaderSpaces
Selection.TypeText Text:=vbTab
Selection.TypeText "Right jystified text"
TabPosition = TabPosition + x
Selection.ParagraphFormat.TabStops.Add _
Position:=TabPosition, _
Alignment:=wdAlignTabLeft, _
Leader:=wdTabLeaderSpaces
Selection.TypeText Text:=vbTab
Selection.TypeText "Left jystified text"
Selection.TypeParagraph
End Sub
--------------------------------------------------------------------------------- Tag: change Tag: 62341
How do i change Word and Exel into my lanuage who is norwgian