Selecting a Field
I am creating a macro which inserts a Filename field into a document. I want
to then resize the font of ONLY the inserted field to 7pt. Presently my
macro reads as follows:
Selection.EndKey Unit:=wdStory
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"FILENAME ", PreserveFormatting:=True
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
With Selection.Font
.Name = "Times New Roman"
.Size = 7
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1
This result was fine, as long as there was nothing else on the line ahead of
the Filename field insertion, which tends to USUALLY be the case. But,
because the macro indicates to return to the beginning of the line to apply
the font size, it also modifies any other text on the same line ahead of the
inserted field. I have tried various combinations of Shift, Ctrl and Alt
along with arrow keys for selecting the field with my keyboard while
recording the macro, but no luck.
So I need to modify the macro somehow so that it only selects the inserted
field instead of returning to the beginning of the line before it sizes the
font of the inserted field.
Any help would be greatly appreciated! Thanks!
--
Elizabeth A. Bañuelos
MOS Master
Microsoft Office Specialist - XP (Word, Excel, Powerpoint and Access)
Hamilton, Ontario, Canada Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112136
Unlinking footnotes/endnotes from text
Can this be done with a macro?
Can this be done at all without third-party software? Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112135
Spellchecking template - receiving error message
We are using a Word template to prepare formatted memos that are then emailed
to our users. I found an article at
http://word.mvps.org/FAQs/MacrosVBA/SpellcheckProtectDoc.htm, which contained
the code to unlock, spellcheck, and relock the template. It works very well
but only on workstations that are set up to allow the user Admin access.
Unfortunately, the vast majority of the workstations in our company are set
up to only grant User level access and the spellcheck function doesn't work
on those, even when we lowered the macro security level to Low. The security
policy cannot be changed to allow everyone Admin access.
Any suggestions to work around this problem and allow the spellcheck to run?
Any help will be appreciated.
Thanks,
John Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112130
Doing translation with VBA
Hi,
My work needs me to translate some objects into Chinese at times. I
come across, for example, a card, a screwdriver and a saw and their
quantity may vary. Since they appear frequently and the translation
is repetitive, I would like to use a VBA programme to do the simple
translation. They appear as lists such as "a card, a screwdriver, a
saw and a stool". Does anyone have idea of how to do it or could
anyone point me to the right direction? Thank you.
Mike Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112127
FirstLineIndent read only in table cell
I am using Microsoft Word 2003 and trying to write a macro which
corrects some indenting problems in the cells of a document. I have a
problem in that I do not seem to be able to set the value of
FirstLineIndent, the indentation.
Here is a macro I've written to try to demonstrate the problem I'm
encountering:
Sub DoAllIndents()
Dim NowIndent As Long
For Each Tbl In ActiveDocument.Tables
For Each Row In Tbl.Rows
For Each cellLoop In Row.Cells
With cellLoop.Range
MsgBox (.Text)
NowIndent = .Paragraphs(1).FirstLineIndent
MsgBox (NowIndent)
.Paragraphs(1).FirstLineIndent = 0
MsgBox (.Paragraphs(1).FirstLineIndent)
End With
Next cellLoop
Next Row
Next Tbl
End Sub
The problem is that setting "FirstLineIndent" does nothing: the second
MsgBox gives the same value as the first one. Apart from using
Range.Paragraphs(1), I've also used .ParagraphFormat.FirstLineIndent
with exactly the same results. The document itself is not read-only,
but "FirstLineIndent" seems to be.
I've googled for some hints but have not been able to make the above
work properly.
Thank you very much indeed for any help with this problem. Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112121
Iterate cells in a table
Hi, this code creates a table in a blank document.
I want to fill the middle-most 5 columns with the numbers 1-5 (in the
for-next loop).
Dim rng As Range
Dim intCount As Integer
Set rng = ActiveDocument.Range
ActiveDocument.Tables.Add rng, 2, 1
Set rng = rng.Tables(1).Rows(1).Range
rng.Cells(1).Split 1, 3
Set rng = rng.Tables(1).Rows(2).Range
rng.Cells(1).Split 1, 2
Set rng = rng.Tables(1).Rows(2).Cells(2).Range
rng.Cells.Split 5, 2
For intCount = 1 To 5
' Fill central column
Next
Any hints would be appreciated,
Graeme. Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112117
Code Hanging - Part II
Recently I posted a question about code hanging after displaying a built-in
dialog that got no response. I now have some more information that might help.
It seems that the code only hangs if the built-in dialog allows the entry of
text for insertion into the document and only if text is actually entered
manually. The dialog in question in my previous post was the 'Caption'
dialog. I've been working with the 'Envelopes and Labels' dialog recently and
ran into the same problem - but only intermittently. So I had a look at when
the code hung and when it didn't and discovered that if I fed the address
information to the 'Envelopes and Labels' dialog programmatically (e.g.
populated it with values from a UserForm), everything was fine. However, if I
added or modified the address information manually - even after populating it
originally from the UserForm - the code hung.
I reckon this is some sort of bug in Word, and I don't for a minute imagine
it's anything under my control. If I manually enter text into a dialog that's
displayed through code, the code is going to hang. I'm just wondering: has
anyone encounterd this problem previously and if you have, have you been able
to find a workaround - or at least a way to 'unhang' the code?
The problem is easy enough to recreate. Just create a UserForm with a single
TextBox and a CommandButton, then add the following code to the click event
for the button:
Private Sub CommandButton1_Click()
UserForm1.Hide
Dialogs(wdDialogToolsCreateEnvelope).AddrText = TextBox1.Value
Unload UserForm1
End Sub
This should display the built-in 'Envelopes and Labels' dialog box with the
value from the TextBox on the UserForm displayed in the 'Delivery address'
field. If you just add the envelope to the document, the code should continue
to run, but if you change the address info manually, it will hang. The code
can't be reset or even modified until you close and restart Word.
--
Cheers!
The Kiwi Koder
Please note: Uninvited email contact will be marked as SPAM and ignored -
unless you want to hire me. ;-) Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112113
Creating a helpful hint pop-up
Is there a way to create a helpful hint pop-up when someone opens a document? Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112106
Word 2007 - Error 4198 when open hyperlink is cancelled
Using Word 2007, I have created a macro to a hyperlink. If I click Cancel
when the window opens that asks "Would you like to open this file?", I get
the Run-time Error '4198.'
This is a macro-enabled document that many employees use for a template so
it must be corrected within the VBA programming if possible.
Here is a sample of the macro:
Sub Acronyms()
On Error GoTo errorHandler
ActiveDocument.FollowHyperlink _
Address:=" http://www.acronymfinder.com/", _
NewWindow:=True, AddHistory:=True
Exit Sub
errorHandler:
Resume Next
End Sub
How do I "trap" the error so that employees won't get the debug error message? Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112104
Search Word doc and record page number
Hi all,
I've tried a few ways to do this (which are gone now, otherwise I'd
post them...sorry), but I'm not having much luck, if any.
What I'd like to do is search a Word doc for terms that are contained
in a text file (each term on a new line), then record the term and the
page number it appeared on to another text file - creating an index,
essentially.
Reading the text file is no big deal, I don't think. I've done that
with VBS before, so it can't be /that/ different in VBA.
What I need to figure out how to do is search the Word doc and return
the page number. I think I have to use a range for this in order to
get the correct page number, but this is all pretty new to me.
So, if anyone can help, I'd appreciate it.
Thanks!
Gabe Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112100
Funky Macro?
I am trying to create a macro that will insert a .jpg saved on the server
into a Word document. I am recording the macro, naming it Signature, and
storing it in Normal. I am using the menu bar for my selections (not using
toolbar buttons). I am selecting menu bar item "DM" (firm created menu bar
item), then Insert, Picture, and Cancel (as jpg's are not stored in DM but
rather on the server), then selecting OK when prompted whether I want Word to
open a document. Then I find the jpg on the server drive, select it, and
click on OK. When I do this outside of recording a Macro, it works
absolutely fine. The result of these steps taken while recording a macro,
simply reads (when viewing the macro in VBA) as follows:
Sub Signature()
'
' Signature Macro
' Macro recorded 4/2/2008 by ebanuelos
'
End Sub
I have even attempted it without using a mouse whatsoever, using the
keyboard for selecting menu bar items and the tab key for selecting "cancel"
when required, etc. and I still get the same result.
Anyone have any suggestions for me? I've never had blank macros happen
before and I'm stuck.
Thanks in advance!
--
Elizabeth A. Bañuelos
MOS Master
Microsoft Office Specialist - XP (Word, Excel, Powerpoint and Access)
Hamilton, Ontario, Canada Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112097
Create a future & past date in Word
If today's date is 20080401 (4/1/08), I would like to have a date
automatically inserted that is 10 years in the future, but 1 day prior:
20180331.
The following field codes work just great for almost every instance:
{={createdate \@ "yyyy"}+10 \# "0000"}{createdate \@ "MM"}{={createdate \@
"dd"}-01 \# "00"}
Problem is, yesterday (4/1/08), those fields yielded: 20180400 -- not a
real date. I know it will require combining the month & day portions of my
fields into a contiguous field to get the subtraction of 1 day correct.
Problem is, even when I try that I still end up with April 00th:
{={createdate \@ "MMdd"}-1 \# "0000"} --> 0400
{={createdate \@ "MMdd"}-1 \@ "MMdd"} --> 400
I would like to try and accomplish this without any programming or add-ins
to my system ... problems with network administrators. Any help would be
greatly appreciated. Thanks--JT Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112096
Different tables
I have two tables in the same document with the same information, which is a
row of values. The information in Row A below is entered as fields in
file/properties/custom. I want the same values to be entered in each table so
the person doesn't have to enter them twice(once for each table) therefore
the field names for each column value is the same in each table. Is there a
way to designate in two different macros (one for each table) that it is a
seperate table so that when Row B is calculated for the second table it
doesn't revert back to the first table.
For example
RowA 3.5 3.7 3.8 9.5 9.8
however each table uses a different value to multiple to get row B. For
example
1st table Row A 3.5 3.7 3.8 9.5 9.8
each value is multiplied by 10 to get row B
1st table Row B 350 370 380 950 980
Seperate Macro same document
2nd table Row A 3.5 3.7 3.8 9.5 9.8
each value is multiplied by 100 to get Row B
2nd table Row B 3500 3700 3800 9500 9800 Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112094
loop validation
I have a form that accepts AutoText entries. If the AutoText entry doesn't
exist I prompt the user with an Inputbox function to enter the entry again.
But there is a line that deletes the previous entry: Selection.Delete. If
the user keeps entering the wrong AutoText entry more is deleted than is
required.
Here is sample code that runs when user clicks OK on form:
On Error Resume Next
Dim x As String
Dim y As String
Selection.GoTo What:=wdGoToBookmark, Name:="MyTest"
Selection.Text = frmAutoTextTest.txtFirstAutoText
Selection.Range.InsertAutoText
Do While Err.Number <> 0
Err.Number = 0
Selection.Delete
frmAutoTextTest.txtFirstAutoText.SetFocus
frmAutoTextTest.txtFirstAutoText = ""
x = InputBox("Enter First AutoText again", "Re-enter AutoText")
Selection.Text = x
If x = vbCancel Then
Exit Sub
End If
Selection.Range.InsertAutoText
Loop
frmAutoTextTest.txtSecondAutoText.SetFocus
Selection.GoTo What:=wdGoToBookmark, Name:="AnotherTest"
Selection.Text = frmAutoTextTest.txtSecondAutoText
Selection.Range.InsertAutoText
Do While Err.Number <> 0
Err.Number = 0
Selection.Delete
frmAutoTextTest.txtSecondAutoText.SetFocus
frmAutoTextTest.txtSecondAutoText = ""
y = InputBox("Enter Second AutoText again", "Re-enter AutoText")
Selection.Text = x
If x = vbCancel Then
Exit Sub
End If
Selection.Range.InsertAutoText
Loop
Unload Me
Thanks for any help,
Jake Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112091
Shifting the screen up after tabbing from a form field
Hi,
I have a form that only permits fill in text into form fields scattered over
10 pages...yet when I tab to a new form field, it bings me to the field at
the bottom of the screen so I then manually have to scroll down to move the
screen up to make it easier to see the text that I am typing.
Is there a way to program the screen to scroll up when I tab to certain
fields so the field will automatically appear at the top or top middle area
of the screen?
Thank you !
Craig Brody Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112088
Table Macro
I'm fairly new to VBA. I'm working on a template that should insert a
pre-designed table from a toolbar. My question is wether I have to design the
table through the macro since it's quite an involved table or wether there is
a way to just select the appropriate table (designed before running the
macro) to be able to be pasted wherever in the document?
Hope this makes sense
Thanks Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112085
Create custom error handling outside of VBA
Hi again,
Is there any way to create error handling that doesn't live inside your
original module? What I'd like to do is be able to add error handling that
lives outside my module, and can be easily updated.
For example, let's say that a new error is given to me by my users. I work
out what the error handling needs to be (e.g. ErrorMsg = MsgBox("Error
number: " & Err.Number & " - Document is locked by password." & vbCrLf &
"Please unprotect manually.", vbCritical, "Error!")) and then I can add this
to my error handling without updating the module itself. I update the
external file (which isn't in use)
I've got another thread open on PrivateProfileString, but I don't think it's
appropriate in this case. While I could use it to get custom error messages
(e.g. ErrorMsg =
System.PrivateProfileString("H:\Errorlist.ini",Err.Number,"Message") I
couldn't actually assign specific handling to the error. (That is, I couldn't
do like a Case statement, whereby it checks Err.Number against the case, and
when a case is found, runs specific code)
Any thoughts?
Thanks again,
Bob Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112078
System.PrivateProfileString to populate array?
Hi everybody,
I've got a module I wrote a while ago, and I had an idea to rewrite a
portion of my code to make it more portable. Trouble is, now that I sit down
to actually do it, I realise that it may be a bit trickier than I first
thought.
My original code is called by another portion of my code, which has run a
lot of initialisation settings for the module. This is run just before
calling a form, so that I can assign values to the form buttons. (Eg
Button1.Label = TrayLabels(1))
Sub AssignTrays()
'Add new printers here
Select Case Printername
Case "PSA075"
TrayLabels = Array("Blank", "Blank", "Blank", "A3")
Case "PSA073"
TrayLabels = Array("Blank", "A3", "SG", "CG")
Case "PSA032"
TrayLabels = Array("Blank", "SG", "CG", "A3")
Case "PSA071"
TrayLabels = Array("Blank", "SG", "CG", "NR")
End Select
End Sub
The code works fine and I've had no issues. However, a drawback to this
style was noted yesterday when we got a new printer, with new tray
assignments. Instead of being able to quickly change the labels, I had to
wait until everybody had gone home and deploy a new version, just to change 1
label. That's when the idea of using an Ini file to get printer names and
tray names occurred to me.
What I'd like to do is create an Ini file which contains
A) Get a list of available printers for a site.
B) A list of what trays are available for these printers.
E.g.
[AvailPrinters]
PSA071
PSA073
PSA075
PSA032
[PSA071]
Blank
SG
CG
NR
The main problem is, I don't know how to read multiple values with
System.PrivateProfileStrings, only a single value. Does anybody have any idea
how I might set about trying to code this?
Thanks in advance,
Bob Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112076
Pulling apart text on a clipboard
Anyone interested in answering this question - I have a lot of background
info below, but the meat of the question is the last paragraph if you're
interested in jumping ahead.
Our company has a "Corporate Resume" system that is antiquated, but I need
to make the best of it. After running a macro, we have a Word document that
is composed of paragraphs that describe what an engineer did on a certain
projects. There are as many paragraphs as projects.
The trouble is that a satellite office of ours decided they needed to
fine-tune this system and further categorize the paragraphs. They do so by
putting numbers in front of each paragraph; frequently, there is more than
one number in front of a paragraph.
I need to be able to check each paragraph and figure out which category(ies)
it is. Then, if it has more than 1 category, pick off each category number
and capture the remainder of the paragraph (sans other numbers), then do that
for the remaining numbers (if I have three categories, I end up repeating the
paragraph three times).
It's easy enuf to copy the paragraph to the clipboard and convert it to
string, then examine it for categories. I also need to keep the paragraph
formatting (specifically, keep certain parts of it bold).
What I'd like to do is look at each characters (or group) of the paragraph
and find out if it's formatted, and how so.
My question boils down to, is it possible to look at a chunk of text on the
clipboard and figure out how it's formatted on a character level, then
remember the formatting and paste the text? Thank you for any thoughts. Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112072
Use a Symbol such as "TM" in a Toolbar Name
Hi,
Is this possible? I want to either superscript the letters "TM" or use the
Trademark symbol in a toolbar name.
I'm not able to make it happen at this point, does anybody know if this can
be done? Thanks for your time. Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112070
How to change the font for specific words?
I'm trying to write a macro to find and change the formatting (e.g.
italic) of particular words. Recording my Replace procedure (which
itself functions properly) only saves ".Format = True" (see below); it
doesn't seem to indicate anywhere WHAT format choices I had made (e.g.
Italics).
Any ideas?
Many thanks in advance!
Tom Kreutz
With Selection.Find
.Text = "(SUBTOTAL)(*)^13"
.Replacement.Text = "\1\2^p"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112063
Multiple Word Sessions - Word 2007
We have an application that uses javascript code to open a new instance of
Word, even if there is already an instance running. This worked fine with
Word 2003, even if there was already a Word sesion open. I could have
multiple Word sessions open and the javascript code would not complain.
I am in the process of converting things for Word 2007 and this code still
works with 2007 except that if Word is already opened when I run the
javascript code, I get an error because there are some templates in the
startup folder that are already loaded. The error tells me that
"templatename".dotm is locked for editing. I don't want to kill the prior
Word session; I simply want to keep the session that javascript opens
separate.
The javascript code uses the following code:
new ActiveXObject("Word.Application")
This establishes the new instance of Word. I know there is a startup switch
/a that will not load any templates, including normal.dot but I'm not sure
how to do that with javascript with this existing code and I don't know if
that's the correct approach anyway.
Does anyone have any ideas on how I can get this to work? Is there some
setup option in Word that specifies how to handle multiple Word sessions? Any
help is greatly appreciated. Thanks. Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112061
how do I have location bullets overlayed on a map
I want to overlay the names of our various locations on a .gif file map and
then be able to click on the names to go to the location pages. When the map
shows on the screen it would have bulets at the various locations. Then when
we add a location we could put a new bullet on the map of Ontario and if it
was clicked on the customer could go to the page of that location. Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112050
Word Template
I created a template that prompts the user using Ask field codes as well as
Fill In field codes.
The problem I am having now is I need to ask a Yes or No question. If yes,
I need to include a paragraph of verbiage as well as adding another page to
the end of the document. I researched the If statements, Include Text field
code and Cross References. I do not know VB too well. The user did not want
a user form. I am on the right track or does anyone have a better idea.
Thanks! Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112049
Use Merge Field in Email "To" field
Created a macro for mail merge with the data coming from SQL database. I
would like to use one of the merge fields(toemail) in the mail merge to also
populate the "To" field in the e-Mail bar. Have already created the function
call EMail, but need help with passing the email address data from the merge
field(toemail) in the mail merge. Below is the code from the mail merge and
email. Thanks in advance for your help...
Sub MailMergeELA(filename As String, subject As String, pdno As String,
Subcase As String, item As String)
' Retrieve the selected letter
Application.DisplayAlerts = wdAlertsNone
ChangeFileOpenDirectory "C:\Program Files\Merlin\Letters\"
Documents.Open filename:=filename, ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
' ELA Letters
' Retrieve data from Merlin database using SQL statement
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:="", ConfirmConversions:= _
False, ReadOnly:=False, LinkToSource:=False,
AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
Connection:= _
"DSN=MerlinRPT" _
, SQLStatement:= _
"SELECT vendorName, title1, pdnosub, hpadmin, aoaddr, aph, afax,
aemail, ocrefno " _
, SQLStatement1:=Chr(13) & Chr(10) & _
" FROM merlin_prod.dbo.LtrELA WHERE (pdno= " & pdno & ") AND
(sub_case= " & Subcase & ") AND (item= " & item & ")",
subtype:=wdMergeSubTypeWord2000
' Merge data with the form letter
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.MailAsAttachment = False
.MailAddressFieldName = ""
.MailSubject = ""
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
Windows(1).Activate
ChangeFileOpenDirectory "C:\TEMP\"
ActiveDocument.SaveAs filename:="junk.doc",
FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True,
WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False
ActiveDocument.Close
End Sub
Function Email(subject As String, toemail As String, ccemail As String)
Dim env As Office.MsoEnvelope
Set env = ActiveDocument.MailEnvelope
With env
' .Introduction = "My introduction"
.item.subject = subject
.item.to = toemail
.item.cc = ccemail
End With
Set env = Nothing
ActiveWindow.EnvelopeVisible = Not ActiveWindow.EnvelopeVisible
End Function Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112047
How do I auto-name a file using form text box?
I have created a form using form text fields. I would like to have the file
auto-save from the text field I have bookmarked as "from", upon exit from
this field.
Does anyone know what macro I would need to use to make this happen?
Thanks Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112046
Word Macro Fails to Launch Intermittently
Hello All,
I have a batch file that launches Word 2003 to open a file and execute
a macro on a file to save that file as HTML. This works fine,
however, sometimes the macro fails to launch, leaving the word
document open until someone manually closes it.
Usually 10 to 15 files will process successfully, and then one will
fail. When the failed file is resubmitted, it will succeed, so it is
not a problem with the document.
Word has been reinstalled, and the macro replaced, but to no avail.
The server is a Win2003 box.
The batch file command line is as follows.
'winword.exe" %1 /n /q /mSaveAsHTML'
Where SaveAsHTML is the name of the macro.
Any ideas? Thanks in advance for your help
Mike Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112041
Loopin through files in a directory
Hi
I need to open a set of files 1 ant a time process the file by running a
macro (already Written) then move on to the next file in the list can anyone
help i am using word 2003 and 2007
Thanks in advance
Mark Reid Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112040
Print to selected port, instead of selected printer?
Each of our departments have a different label printer, but they are all set
up on lpt3. We have a label macro that is used by these departments and we
would like to have that macro automatically print to lpt3. Is there a way to
set the activeprinter to the lpt3 port without using the printer name? Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112030
Getting Spell Check to work in Text Form Fields
Hi,
I have a form that includes many text form fields in which people fill in
with a lot of text...how do I tell the users who fill in the form with text
to run the spell checker to check for spelling errors on what they typed
within those form fields?
Thank you
Craig Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112020
WildCard
Hi. I have a problem with wildcard. I use Ms Word 2003 and use to Find and
replace dialog.
I have current text:
text
[[ text [[ name [ text ]] text ]]
text
I want to find this [[ text [[ name [ text ]] text ]]
I use wildcard and this \[\[*\]\] but Word find this [[ name [ text ]]
Plecae help me how I can find [[ text [[ name [ text ]] text ]]
thank you Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112017
Word 2007 should allow floating toolbars w/ custom text & icons
Word 2007 is an absolute disappointment for this power user. You have
removed the most useful tools for customization: (a) floating toolbars, and
(b) fully customizable icons. Here are two other people whose feelings are
nearly identical to mine:
http://www.tutorials-win.com/WordDoc/Safely-Uninstall/
"I like Word 2007 not. MY productivity has crashed. My clients expect
quick turnaround on their work, but operations now take me twice as
long."
"Trying to use it is eating into my time with my family. I have to make
two or more mouse clicks to attain functios I used to with a single
click. Ribbons disappear when I need them, just because I move the
cursor outside some region in the document. I cannot create custom
toolbars to remain in sight at all times. I can't insert formatting and
other functions into the toolbars in a logical position. I cannot dock
toolbars to the side or the bottom, or have them float I am forced to
add operations to this "quick access" toolbar...which now holds
everything possible because I need the operations handy. I even bought
the addin tool to give me back my menus and such, but my ability to
keep my work on pace has been eroded considerably."
http://www.awomantoldme.com/women/how-to/29510935/cutom-toolbars-in-2007.aspx
"I just got Office 2007 and I want to cry. I used to have several
custom toolbars for my Macros (about 30 macros on 3 different
toolbars). Now I only have the Quick Access toolbar and there is no way
to tell which macro is which without hovering over the button. On the
toolbar, I could use text, but that doesn't seem to be an option now.
Plus, I don't want to have to put all 30 macros on the Quick Access
Toolbar. Is there anything I am missing here?"
----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/office/community/en-us/default.mspx?mid=545cbb3f-3c98-43d2-97c8-abeeaa4f9be0&dg=microsoft.public.word.vba.general Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112015
Finding for lowered or raised character
Hi,
I am trying to find a raised character in Word. I have the following code:
Dim MWord As Word.Application
With MWord.Selection.Find
.Text = ""
.Font.Position = 5
End With
This code works fine but if the value I used for ".Font.Position" is a
decimal like below:
.Font.Position = 0.5
, it cannot find what I am looking for.Was this a bug or was I missing
something? If I manually searched for the raised character using the Find and
Repalce dialog box, it can actually find the character whether it is a
decimal or a non-decimal. The info in the dialog box has: "Format: Raised by
0.5 pt." but when done programmatically, it wasn't found. Please enlighten
me. Thanks. Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112013
First page with company logo, bookmarks, other pages only bookmarks
I have a template which my program adjusts via vba for the various
companies that use it. I need to have a first page with company logo
followed by data which is inserted at bookmarks. Later pages would
repeat only the inserted data at the top of the page. I'm not sure how
to do this. Seems like the company logo etc and the data that's inserted
at bookmarks must be in the header, but how to not repeat the company
logo?
Before the doc is delivered to users as a finished product the dot that
contains the custom code is defreferenced, so I can't use any vba tricks
to show or hide in the final doc (at least that's what I understand).
Currently the header with company logo etc repeats for every page.
The bookmarks and the data that gets inserted into them are immediately
below the header in the body of the doc and show only on the first page.
I need the data that's inserted at the bookmarks to repeat at the head
of every page, but no the company logo etc.
I know there is a page setup option for 'different first page' but I'm
not sure what it does, I'll be reading up on that. Tag: how about product ID 89388-861-1060037-65764 ? Tag: 112004
Client receives blank word documents from me
This may have been covered before, but please help.
One of my clients works from a mac. I have a pc and a mac. She's using
office 2008, I'm using office 2003 on my pc and 2004 on my mac.
Every word document I send her is blank - regardless of what computer I'm
using or what version of word.
I don't have this problem with any of my other clients and she doesn't have
this problem with anyone else who attaches word docs to emails.
She can open rtf files from me, but if I need to track changes, she can't
see them in rtf.
To make this even more mysterious, I can open all of the word docs she sends
me and see her tracked changes - on both of my computers....
Anyone know what the heck is going on?
Many thanks in advance if someone can help me solve this very strange and
annoying problem!
Susan Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111999
Printing Doc Sections to PDF
Hi, I'm using the following macro to print a mailmerged document's sections
to PDF Files.
How do I call a text value from each section, e.g. the 65th word (the last
word on the fifth row of the table) and depending whether i = an Odd or Even
number call the document "Report" or "Appendix A" respectively?
So that the filename is something like "11125 Report.PDF", or "11125
Appendix A.PDF"
Sub PrintSections()
Dim i As Long
For i = 1 To ActiveDocument.Sections.Count
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="s" & i, To:="s" &
i, _
OutputFileName:=(i & ".jpg")
Next i
End Sub
Thank you
DDawson Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111997
add checkbox to table programatically
Any coding out there that would automatically add checkboxes to a table field
if a new line is created?
I have a table that has checkboxes in 3 fields. If the user is on the last
line of the table and tabs, a new line is added as is the way with a Word
table. What I want to do is be abel to have the checkboxes added
automaticallyt.
TIA,
--
Cyberwolf
Finder of Paths, Hunter of Prey
Ghost of the Night, Shadow of Day
The Wolf Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111994
Creating a directory from within Word VBA
Hi all,
I'm creating a little VBA script within Ms Word, wanting the script to
change directory before writing a file, using the ChangeFileOpenDirectory
method. It works fine. But what if the directory does not exist? Then I want
the script to create it. Can you please tell me how I make it do so?
Thank you very much in advance.
Jo Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111991
Is there any way to convert table from character graphics to normal
There is the table made by from character graphics (sample of the
document: http://wordexpert.ru/wp-content/uploads/_0/temp_table.doc).
Is there any way to convert this pseudo-table to normal table (for
Word)?
Thank you. Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111990
=?Utf-8?Q?=E2=80=9CFormatting_..._Too_Complex_...=E2=80=9D?=
Iâ??m developing a macro which takes information from an active document and
opens two new documents and modifies the data from the active document and
places the modified information into the two new documents. Everything seems
to work fine until I start working with larger files.
At that point I received a Microsoft Word msgbox message saying: â??The
formatting in this document is too complex. Please full save the document
now.â?? And its has an â??OKâ?? button. (And it wouldn't let me save either
document.)
I assume that Iâ??m running up against a memory problem, the larger the file,
the more memory it takes, yes? Will saving these documents while the macro is
running help with the memory problem? How can I find out when I need to save
these documents? And what names should I save them as? (I was going to leave
that to the user to decide after the macro was run.) And what is â??full saveâ???
Any help will be greatly appreciated, Iâ??m way over my head on this.
(I'm using Word 2000.)
Steven Craig Miller
New Lenox, IL (USA) Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111989
how to track which section it's at
Hi,
I have a question i need to ask of you in regards to word 03. In the report
word document, I have a button called "insert picture". What it does is it
will bring up the insert picture windows dialog box and then prompt user for
the text message for the picture.
for example,
somewhere in the word report, we have something like as follows
Section 2. Light Bulb Prices
some texts ........................
picture
Figure 2.1 List of Light Bulb prices
some texts ........................
The number "2" in the Figure comes from the Section number. If the Section
is 3, then it should show Figure 3.1
Section 2 - this section is generated by Bullets and Numbering.
My question here is how do i know which Section it is now at?
I have the following code but it gives the wrong answer. The answer should
be 2 but it says 8 (which i think, is the page number)
Sub InsertPicture()
Dim srange As Range
Dim ssection As Section
Dim i As Long
i = Selection.Information(wdActiveEndSectionNumber)
Set srange = Selection.Sections(1).Range
srange.Collapse wdCollapseEnd
Set srange = ActiveDocument.Sections(i + 1).Range
srange.Collapse wdCollapseStart
Selection.TypeParagraph
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Dialogs(wdDialogInsertPicture).Show
Selection.TypeParagraph
Selection.TypeText ("Figure " &
srange.Information(wdActiveEndSectionNumber) & "." & pictureCounter & " - " &
pictureText)
Selection.TypeParagraph
Selection.TypeParagraph
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
End Sub
Thank you in advance Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111985
Help - Find And Replace - one word at a time
'Hi experts, I need your help please!
I have written a number of find and replace' macros in Word, but I need one
to interact with me and ask me every time whether or not I wish to replace
the word that has been found.
1. First, I want to run thru a word document and for every instance of "his"
ask me if I want to replace it with "her". Preferably the normal "Find and
Replace dialog box should open so I could just click on "Replace" or "Find
Next", but I can't work out how to make the box appear each time the macro
finds "his".
2. Also it would be nice if the dialog box were out of the way so I could
see the sentence in question. (but this isn't critical.)
3. Then I want to expand the macro to include a list of other words to run
the same steps - eg "him" to be replaced sometimes with "her", "mine" with
"ours" etc.
Any ideas, anyone, please? Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111977
Help with a teaching assignment needed
Hi,
Hope that somebody can help me with the following: I need a macro to create
a cloze (or fill-in the gaps) assignment for my language class.
I have a pre-formatted documents with the following structure:
<heading 1>
<heading 2>
<story 1>
<heading 1>
<heading 2>
<story 2>
Now, each story has some words or phrases marked with, say, character style
â??InlineVocabularyâ??.
I have to:
1. select all these words and phrases
2. move them to the end of the <story 1>
3. format them as a list, style â??WordsToInsertâ??
4. sort the list
5. convert the list to two columns
6. remove these words and phrases from the story 1, substituting them by â??1
_____â?? element
7. do the same to the second story, the third story, etc.
This should look something like this:
1.1 CALLING TECH SUPPORT
I recently (1). _________ for a new (2). _________ for my office, using (3).
_________.
1. DSL
2. ISP
3. Singed up
Actually, I have a macro, but it just doesnâ??t work as expected and something
is wrong with the sorting part:
Sub Vocabulary()
'
' AutoExit.MAIN Macro
'
'
Dim rDcm As Range
Dim LCnt As Long
Set rDcm = ActiveDocument.Range
rDcm.InsertAfter vbCrLf
With rDcm.Find
.Style = "InlineVocabulary"
While .Execute
rDcm.Select ' for testing
ActiveDocument.Range.InsertAfter rDcm.Text & vbCrLf
ActiveDocument.Paragraphs.Last.Previous.Range.Style = "WordsToInsert"
Wend
End With
Set rDcm = ActiveDocument.Range
'With rDcm.Find
' .Style = "WordsToInsert"
' If .Execute Then
' rDcm.Select
' Selection.End = ActiveDocument.Range.End - 1
' Selection.Sort
' End If
'End With
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Style = "InlineVocabulary"
While .Execute
LCnt = LCnt + 1
rDcm.Select ' for testing
rDcm.Text = "(" & CStr(LCnt) & ") _________"
rDcm.Collapse Direction:=wdCollapseEnd
Wend
End With
End Sub
Thanks in advance,
Arthur N Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111972
is it possiable text on the photo at all??
I actually have my wedding invitation i can bring it up but for some reason i
cant text the wedding info on it .please help i have 12 weeks till my wedding.
Thanks a Million Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111967
How to do copy-and-paste easily between a userform and a blank Word
Hi,
I have created a userform which takes input of information.
When I move the mouse out of the userform and click on another Word
document to copy some information, it forbids me to do so. I can't
copy any information on that Word document which I want to paste to
the userform. May I ask how I can switch to another Word document
from a userform, copy information from there and paste it to the
userfom conveniently? Thank you.
Mike Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111965
HyperLink editing in Word VBA - Hyperlinks.Item(Index) value not r
Hello;
First my purpose.....to help a friend with an office automation problem
(see other posts I have made) with updating the text that is displayed in
hyperlinks. It may be that using some other field or tag may work
better..opinions and solutions please...
NOTE: Some of the below code is from other posts/contributors in this forum
(Thank You macropod!).
The problem is in legal pleading type pages, there needs to be a table with
a column of crossreferences that list the page and linenumber (that may not
be possible to do automatically I am finding) or section/heading/numbering.
Some type of fields will automatically update on F9 like page number using
the PAGE or PAGEREF field code. Same thing with almost everything except line
number. In order to exploit if a line number solution is possible I am
enumerating the various properties of the fields. At the moment (having never
used the office automation but having C#/Ansi C/ and some VB5-6 experience) I
am struggling to get the included below code to do the following (it seems
pertinent to do, but if I am in error please advise me so):
Cycle through all the fields in the ActiveDocument
<seems to work> If the field is a hyperlink, display the Text to display,
target, address, subaddress, index number.
<does not work> Then using the index number, access the hyperlink object
from the hyperlinks collection using the
index number to get/display the properties.
<note coded yet> If the field is a bookmark,
display the Title of the bookmark,
display the page it is located on,
most importantly (I think) is get the
character range (ie start and end)
so that I might be able to get the
linenumber from one of the properties of the range object
after setting the range object to the
bookmarks start and end position.
<note coded yet> For each hyperlink, change the Text to display to the
following format:Page/LineNumber or Page,LineNumber
<seems to work> Count total of HyperLinks in document
Please advise where I have improperly coded or assumed the schema. I am
working in Office 2002 SP3.
References are:
Visual Basic for Applications
Microsoft Word 10.0 Object Library
OLE Automation
Normal
Microsoft Office 10.0 Object Library
Do I have to Dimension a hyperlink object and then if the field.type is
hyperlink, then do hyperlink=field in order to get the Address? Or is the way
I am trying below the better approach?
Sub HLinkTest()
Dim oFld As Field
Dim oCount As Integer
Dim oRange As Word.Range
With ActiveDocument
.Range.AutoFormat
For Each oRange In .StoryRanges
Do
For Each oFld In oRange.Fields
If oFld.Type = wdFieldHyperlink Then
If Left(oFld.Result, 7) = "mailto:" Then MsgBox
"oFld.Result= " & oFld.Result, vbOKOnly, "oFld.Result"
If Left(oFld.Result, 7) = "mailto:" Then MsgBox
"oFld.Kind= " & oFld.Kind, vbOKOnly, "oFld.Kind"
If Left(oFld.Result, 7) = "mailto:" Then MsgBox
"oFld.Code= " & oFld.Code, vbOKOnly, "oFld.Code"
If Left(oFld.Result, 7) = "mailto:" Then MsgBox
"oFld.ShowCodes= " & oFld.ShowCodes, vbOKOnly, "oFld.ShowCodes"
If Left(oFld.Result, 7) = "mailto:" Then MsgBox
"oFld.Index= " & oFld.Index, vbOKOnly, "oFld.Index"
If Left(oFld.Result, 7) = "mailto:" Then MsgBox
ActiveDocument.Hyperlinks.Item(oFld.Index).Target, vbOKOnly,
"ActiveDocument.Hyperlinks.Item(oFld.Index).Target"
If Left(oFld.Result, 7) = "mailto:" Then MsgBox
ActiveDocument.Hyperlinks.Item(oFld.Index).Address, vbOKOnly,
"ActiveDocument.Hyperlinks.Item(oFld.Index).Address"
If Left(oFld.Result, 7) = "mailto:" Then MsgBox
ActiveDocument.Hyperlinks.Item(oFld.Index).SubAddress, vbOKOnly,
"ActiveDocument.Hyperlinks.Item(oFld.Index).SubAddress"
If Left(oFld.Result, 7) = "mailto:" Then MsgBox
ActiveDocument.Hyperlinks.Item(oFld.Index).TextToDisplay, vbOKOnly,
"ActiveDocument.Hyperlinks.Item(oFld.Index).TextToDisplay"
oCount = oCount + 1
End If
If oFld.Type = wdBookmark Then
MsgBox "BM oFld.Result= " & oFld.Result, vbOKOnly,
"oFld.Result"
End If
Next oFld
Set oRange = oRange.NextStoryRange
Loop Until oRange Is Nothing
Next oRange
MsgBox "Total Detected HyperLinks=" & oCount
End With
End Sub
Thanks...I feel the programming pain, where is the gain?
Rob Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111964
=?ISO-8859-1?Q?Insertion_of_nonbreaking_space_between_a_number_and_?=
Dear Experts:
I would like to be able to automatically insert a nonbreaking space
between all instances of a number and the character set =B0C (ANSII
Value of 176) using VBA. For example:
40 =B0C or 5 =B0C
I know how to do it using the Find And Replace Dialog Field. But I
also would like to be able to do it programmatically. The "Find.Text"
Line is enough.
Help is appreciated.
Thank you very much in advance.
Regards,
Andreas Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111960
LINEREF ...Where is it?
Help, It is easy enough to discover the page number of a bookmark using PAGE
or PAGEREF (w/o even programming). If Line Number is turned on for the active
document how does one find the line number of the bookmark on a given line?
On several proposal documents we must show the page and line reference of the
related item. To do this, we place a bookmark attached to the selected text
or object, then use the PAGE or PAGEREF field to get the page#, but we have
to type the line number in manually......isnt this supposed to be helping us
to not crane our necks at a monitor...?
Sincerely cross(eyed)
Rob Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111953
macro for Office 2007
good afternoon,
i'm using Office 2007 on Vista and would like to make a macro for a
template. the template uses building blocks (date calander and select from
drop down list) in multiple locations.
i would like the macro to save using the date that was selected from the
calander and the text that was entered into one of the fields (the person's
name.)
if this was in excel, i could do this because the file name could be
referenced via the cell values, i could save the file and email it and leave
the template intact. In word, i have no idea where to start...
any suggestions, hints or ideas?
thank you,
jat Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111947
Extract Address from existing document
I've been trying to update some old WordBasic code (written by someone else)
that no longer works in Word 2003.
We have an label macro for our users that lets the user pick what type of
mailing label they need (USPS, UPS, FedEx, etc.) then asks if they want to
hand input the address, pull an address from our database, or pull the
address from an open document. While the rest of the code has been updated
for some time, this piece worked, so we just left it alone (the "if it's
isn't broke, don't fix it" attitude!)
I've tried several things using the Wordbasic conversion tables in Word, but
haven't had any luck. I'm hoping someone here can help.
The code that DID work at one time is:
Dim dlg3 As Object: Set dlg3 =
WordBasic.DialogRecord.ToolsCreateEnvelope(False)
WordBasic.CurValues.ToolsCreateEnvelope dlg3
LabelAddr$ = dlg3.EnvAddress
Everything I try comes up with a blank address. I've tried the below code
with both showing the dialog box and not showing it, (and I do not want to
show it) and either way, LabelAddr$ always comes up blank, even though when
it does show the box, the address is in the dialog box.
Set myDialog = Dialogs(wdDialogToolsCreateEnvelope)
With myDialog
.extractaddress = True
' .Show
End With
LabelAddr$ = myDialog.EnvAddress
Anyone have any ideas on how to either convert the WordBasic Code above or
how to extract the address from a letter without using the dialog box at all? Tag: how about product ID 89388-861-1060037-65764 ? Tag: 111942
how about product ID 89388-861-1060037-65764 ?
or product ID 89388-861-1060037-65764 is trial?