Copy Paste (special-unformatted) from Excel to Word
Hi
I'm trying to copy-paste (unformatted), a series of cells from excel into
Word. I've got the below macro which does some of this but it keeps pasting
the whole table either as a picture or a normal table (if you use the
disabled line instead of the enabled paste line).
However, if I manually copy-paste special and select unformatted text I get
a load of text and no tables or borders which is what I want.
Any ideas how to achieve this with the below macro?
Sub OpenAWordFile()
Dim wordApp As Object
Dim fNameAndPath As String
ActiveSheet.Range("I5:I51").Copy
fNameAndPath = "C:\Documents and Settings\tom.jordan\My
Documents\Projects\FFEC Headed Paper.doc"
Set wordApp = CreateObject("Word.Application")
With wordApp
.Documents.Open (fNameAndPath)
.Visible = True
.Selection.PasteSpecial DataType:=wdPasteText
'.Selection.PasteAndFormat (wdPasteDefault)
.Selection.WholeStory
.Selection.Font.Name = "Arial"
.Selection.Font.Size = 11
End With
Set wordApp = Nothing
Application.CutCopyMode = False
End Sub Tag: How do I customize a toolbar for an addin template Tag: 105165
Word 2002 TOC format does not update correctly
I have a big document and I inserted a table of contents. I selected
specific formatting for each TOC level, but my formatting is not
applied. Instead the formatting of the TOC (fonts type, font size,
Bold, Italic, ...) is all wrong.
Can you please tell me how can I modify those styles?
Thank you
P.S. If there is already a response to this question please help me
find it. thanks Tag: How do I customize a toolbar for an addin template Tag: 105161
Extracing scetions of a document
Hi
I am after some advice on how to proceed. I would like to write some code to
extract certain sections out of a document and copy them into a new document.
Is it better to use sections or bookmarks? These sections may span multiple
pages.
Any advice would be very gratefully received.
Cheers
Dan Tag: How do I customize a toolbar for an addin template Tag: 105159
changing a certain word in many files.
Hi everyone ,
I have a folder with hundreds of one page word documents. I want to use VBA
to search through all these files and change a certain name (e.g. New York)
to something else (e.g. los angeles) and save the file and go to the next
file.
Any thoughts?
Any help greatly appreciated.
--
Best regards,
Harvey Tag: How do I customize a toolbar for an addin template Tag: 105146
EXE that invokes Word won't run macros
I have a Windows 2003 scheduled task parsing process that calls Word 2003
and runs a specified Word macro, however, the macro will not run unless the
user is logged in. I know you can configure the Word Document Properties,
via the identity tab, to use a specific user to run the application,
however, I want to use the launching user and not require a user to be
logged into windows. I've tried security settings in macros with no luck.
Any ideas?? Tag: How do I customize a toolbar for an addin template Tag: 105143
Spawned document from Template (Dot) loses macros
Here is a screenshot I am working on:
http://www.jkfweb.com/files/Example.JPG
The file is a .Dot template file. It works great normally when a user opens
from the Template and fills in the appropriate information.
I have a few users who want to open the file, fill in there name and the
Company Name and other appropriate fields and then save that as a .dot file.
This would allow them to not have to re-type and look up the information
everytime.
The problem is the macros are apparently not being copied when word spawns
document1 from the template. I'm assuming this is normal word behavior, but
haven't been able to find a solution on word.mvps.org and a quick search in
newsgroups didn't find the solution either.
Any ideas how to get the macros to go into the newly spawned document as
they are used to create new rows, do some error correction, and formatting of
fields.
Thanks in advance for any help. Tag: How do I customize a toolbar for an addin template Tag: 105140
Toggle symbols with VBA
I'm trying to set up a roster where I can click on a symbol in front
of a person's name and it will change from an "X" to a "O".
I'm an expert at Excel VBA, but not familiar with Word VBA.
Can someone give me some ideas on how I could set up a macro to allow
the user to check on a symbol (or character) in front of a person's
name in a list and it would toggle between 2 or 3 symbols?
The list will be dynamic, so I need to write some generic code that
can identify which symbol is clicked on and toggle it to the next
symbol.
Thanks.
John Tag: How do I customize a toolbar for an addin template Tag: 105134
Remove character style with direct formatting
I have text styled with a custom character style. Some of that text also has
direct formatting applied (bold, ital, etc.).
I need to remove the character style, but retain the direct formatting.
Possibly I also need to retain any font formatting provided by the style as.
I can do this:
For Each c In Selection.Characters
Set f = c.Font.Duplicate
c.Font.Reset
c.Font = f
Next c
but this is slow and I keep thinking I'm missing a simpler, faster way to do
this. Any suggestions? Tag: How do I customize a toolbar for an addin template Tag: 105132
Adding in an XML Schema
I am using Office 2003 Professional. I am trying to follow an example for
adding an XML schema to a Word document and I get the following error: "The
XML expansion pack or schema file could not be installed". I can't see
anything wrong.
Here is the xsd code:
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="urn:schemas-microsoft-com.office11demos.WordProductsSD"
targetNamespace="urn:schemas-microsoft-com.office11demos.WordProductsSD"
elementFormDefault="qualified"
attributeFormDefault="unqualified" id="Contract">
<xsd:complexType name="contract">
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="CaseCode" type="xsd:string" />
<xsd:element name="Casediscription" type="xsd:string" />
<xsd:element name="element1" type="xsd:string" />
<xsd:element name="Nextdateofhearin" type="xsd:string" />
<xsd:element name="summary" type="xsd:string" />
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema> Tag: How do I customize a toolbar for an addin template Tag: 105130
DSO file fails with word 2007 docx files of size zero byte.
Hi
I am using dsofile.dll(latest, which supports office 2007 formats)
to set attributes of office files. The dsofile fails with .docx files
if the file size is 0 bytes(Such a file can be created by
rightclicking on desktop and selecting New ->Microsoft Office Word
Document. If you right click on the created file and select
Properties, It shows Seze as 0 bytes). Is there any fix/workaround
available for this bug?
Thanks in advance, Tag: How do I customize a toolbar for an addin template Tag: 105127
Conditional macro to change font
Macro programmers -
I need a macro that changes fonts in a document from:
Goudy Old Style to Garamond
-and-
Avenir 45 to Gill Sans MT
If there are other fonts in the document I want to leave them as is. I
am only concerned with the above 2 fonts.
Thanks in advance for your help. Tag: How do I customize a toolbar for an addin template Tag: 105126
User to Specify Starting Number for Sequential Numbering
I am using this macro (courtesy of Doug Robbins with help from Jay Freedman)
to sequentially number certificates where data other than the serial numbers
is in ask fields.
The macro is in a template and runs automatically on Document_new. My
problem is that I need the user to specify the starting serial number every
time, without opening the settings.txt. Can this be done with a user form?
Grateful for some help with this, thanks.
Sub SEQserialnumber()
'
' SEQserialnumber Macro
' Macro created 11/09/2007 by Sharon
'
Dim Message As String, Title As String, Default As String, NumCopies As
Long
Dim Rng1 As Range
' Set prompt.
Message = "Enter the number of copies that you want to print"
' Set title.
Title = "Print"
' Set default.
Default = "1"
' Display message, title, and default value.
NumCopies = Val(InputBox(Message, Title, Default))
SerialNumber = System.PrivateProfileString("C:\Settings.Txt", _
"MacroSettings", "SerialNumber")
If SerialNumber = "" Then
SerialNumber = 1
End If
Set Rng1 = ActiveDocument.Bookmarks("SerialNumber").Range
Counter = 0
While Counter < NumCopies
Rng1.Delete
Rng1.Text = SerialNumber
ActiveDocument.PrintOut
SerialNumber = SerialNumber + 1
Counter = Counter + 1
Wend
'Save the next number back to the Settings.txt file ready for the next use.
System.PrivateProfileString("C:\Settings.txt", "MacroSettings", _
"SerialNumber") = SerialNumber
'Recreate the bookmark ready for the next use.
With ActiveDocument.Bookmarks
.Add Name:="SerialNumber", Range:=Rng1
End With
'Next line added to update { REF SerialNumber }
ActiveDocument.Fields.Update
ActiveDocument.Save
End Sub Tag: How do I customize a toolbar for an addin template Tag: 105125
Macro/Code to Delete Current Section
Anybody know the code to delete the current section in a Word 2000 document.
I know the code for deleting section 1, 2, 3, etc. but I need the code for
the current section.
Thanks in advance.
Mickey Tag: How do I customize a toolbar for an addin template Tag: 105123
Word file with 6 links to one excelfile with vba code, run that code 6 times on update
Hi,
I have a word file with six links to a excel sheet. That excel sheet
run vba code on workbook_open event.
When opening the word file, it seem like the excel code run for each
link. Any workarounds?
Kind regards
Tskogstrom Tag: How do I customize a toolbar for an addin template Tag: 105118
How do I compare dates in Word 2007?
Is there some esoteric programming practice within Word 2007 that allows the
comparison of dates? I.E., {Date1} <= {Date2} {Date1} is merged field and
{Date2} is today's date {DATE}. So far, I have found nothing that works. I
am attempting to create a Mergeformat renewal document when today's date has
passed a merge field date. Tag: How do I customize a toolbar for an addin template Tag: 105110
select all rows of a table except the first row
Hi
I have a macro that does a bit of formatting to any table that the cursor is
placed in. I can select the whole table easily:
Selection.Tables(1).Select
and can select individual rows too:
Selection.Rows(1).Select
but I now need to select every row except the first one (2-x) where x could
be any number, depending on how big the table is. Maybe some way of counting
the rows in the table first (x) and then using that number to select rows
2-x? Or maybe select row 2, perform the action, and move to next row and
repeat until there are no more rows in table 1?
Any other suggestions?
What would the syntax be?
thanks.
Mike Bourke
Sales Information Designer
IBM New Zealand Limited
Internet email : mbourke@nz1.ibm.com
+64 4 462 3534 DDI
+64 4 576 5615 fax
+64 21 679 746 mob
--
MB. Tag: How do I customize a toolbar for an addin template Tag: 105108
cant open paper says selection is locked
paper due tomorrow it said somethin like program options update definitions.
what does it mean? help!!!! i need my paper now!!!!!!!!!!!!!!!!!! Tag: How do I customize a toolbar for an addin template Tag: 105105
Macro to auto update bookmark dates
Hi All,
I have created a template which uses bookmarks and fieldforms to get data
from our database. we are a school and we have students always starting on
mondays except for public holiday. here is my problem
below is a macro found at woody's (great website)
I have 2 bookmarks (E_ST_DATE) & (public holiday) but when the macro is ran
it seem to caculate before e_st_date is updated because I get a return of
31/12/1899 as my result
Sub AutoNew()
Selection.GoTo What:=wdGoToBookmark, Name:="publicholiday"
Selection.InsertAfter Format((E_ST_DATE + 1), "dd/mm/yyyy")
End Sub
What I want to achieve is e.g (e_st_date = 10/09/2007 then publicholiday =
11/09/2007) The trouble is thou e_st_date will always change and I just want
to add 1 to wat ever date that is.
Please help Tag: How do I customize a toolbar for an addin template Tag: 105098
Calling a macro
I have a VBA macro that I am using and I want to call another macro. I have
been tried the two versions of calling a macro below.
Application.Run MacroName:="[PrintHRFormsRep]"
Application.Run "'Shreveport.doc'!NOH.PrintHRFormsRep"
But I keep getting an error message that says:
Unable to run the specified macro.
The document that I am working in has a range set called noticeplus. Then I
want to call a macro that will open another document, print it, close it and
revert back to the previous active document. Both macros work independently,
but I want to be able to use them together.
It occurred to me on the way home tonight that maybe it had something to do
with the range being set. Is there another way to call a macro when a range
is set?
Both macros are in the same template and module.
Thanks for any help. Tag: How do I customize a toolbar for an addin template Tag: 105096
Form repaint problem
I have a VBA form to provide the user with status on a long-running macro.
Normally, the status updates happen every few seconds without error.
Sometimes, however, the form doesn't update at all, and can even generate a
"(Not Responding)" error in the form's title bar. The macro completes
successfully, but the user thinks it's frozen.
I'm calling form.Repaint after I update the status text. Why might that be
working some of the time and not all of the time? It does seem to be related
to switching from Word to another app and back again, but it's not consistent.
I've also heard of the DoEvents command, to yield control to the OS, but
I've seen conflicting advice about how and when to use that.
Any suggestions? I can provide code samples, but really, I'm just updating
the text in the form and then calling .Repaint.
Thanks,
Ben Tag: How do I customize a toolbar for an addin template Tag: 105095
Word from Excel PasteSpecial Bitmap Problem
Dear All,
I am having a very strange and odd problem with Excel and Word.
If you could kindly propose any solution ideas, I shall appreciate it very
much.
I have a reporting VBA application on the Excel. Smoothly produces all the
reports.
I have to put the reports in a Word application. The reports are not fixed
row and column sizes. I have to generate a Bitmap image of the Excel report
and
tried to Paste it in the Word Application. Very strangely, on the very first
runs no problems. It worked, I had the reports Bitmap pics on Word beatifully
as I wanted but then later something happened, may be the ghost in the
machine.
Excel VBA is copying the range and sending it to the Word application but,
the pasted bitmap is a blank object, sadly, very sadly nothing inside.
In order to complete my reports on time, I tried a backdoor tactic and
created a Word macro doing the PasteSpecial Datatype:=wdPasteBitmap and
assigned it to a keyboard shortcut macro. Bingo! It worked. However it is
taking so long to complete a full set of report with approx. 200 x 30
Cntrl-Qs and shifting between the applications is awfully open to error. I
have tried another backdoor route because I were running short on time, I
tried the Sendkeys method but unfortunately, the same ghost in the same
machine, very first few runs it worked, then generated empty objects. I
cleaned the Clipboard if incase there is a memory related problem. No
progess. I tried to pause the code before and after the PasteSpecial steps.
No progess. Then I wondered if the Excel Bitmap function is not working
properly so I tried a code to generate my own bitmap pictures, which worked
fine, but the same ghost in the same machine, blank pages were there after
the second or third runs so sadly and so misfortunately.
I tried the 2007 and 2003 vers. of Excel but sadly, very same.
I am working on a licenced XP Pro and licenced Office Pro Pentium 4 with
4GbRAM and lots of disk space. If you may need to see the code, I shall send
the code as well.
If some Guru could help fiding the ghost in the machine, I shall be more
then gratefull.
Regards,
VBANovice trying to find the Ghost in the Machine Tag: How do I customize a toolbar for an addin template Tag: 105091
microsoft word
Hey i really want to download Microsoft word for Xp computers and i was
wondering how i did this. If you use a website can someone tell me what i
have to do. Now i'm starting my coursework i really want to get started with
WORD!
i would be grateful if anyone can tell me how to download microsoft word
from the website.
Kind Regards
L x Tag: How do I customize a toolbar for an addin template Tag: 105089
nextPage sectionBreak
hello everyone
I have a document which I need to break into sections(nextPage).
Im doing a search for 3 asterix marks and when found, insert the
sectionbreak.
I need to run the code until the end of document only once everytime it is
run.
Do I have to delete the existing section breaks first.
heres the code I have so far. It keeps looping nonstop
Sub letsDivide()
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="***", Forward:=True, Wrap:=wdFindContinue,
MatchWildcards:=False _
) = True
Loop
End With
Selection.InsertBreak Type:=wdSectionBreakNextPage
End Sub
Any help will be appreciated.
thanx
ahmed Tag: How do I customize a toolbar for an addin template Tag: 105088
calculate values from a content control
hello all,
i have a content control in word that accepts values such as High, Medium
and Low.
I'd like to add a summary at the top of this table that calculates the total
High Medium and Low. How do I go about doing this automatically? Tag: How do I customize a toolbar for an addin template Tag: 105085
Sequential numbers to appear twice on each document
I have a simple form that I to print want multiple copies of. I have looked
at Doug Robbins macro at
http://word.mvps.org/FAQs/MacrosVBA/NumberCopiesOf1Doc.htm and would like to
use it. What I can't work out is how to get the same sequential number to
appear in 2 places on each copy.
e.g.
Copy 1 has: 123456 & 123456
Copy 2 has: 123457 & 123457 Tag: How do I customize a toolbar for an addin template Tag: 105083
How can insert acute accent for selection of character into word?
Hi. How can insert acute accent for selection of character into word?
For example, I inserting acute accent like this:
Selection.InsertSymbol Font:="Times New Roman",
CharacterNumber:=769, Unicode:=True
But it replace my selection character. If I add:
Selection.Collapse direction:=wdCollapseEnd
That nothing do.
There is screenshot that show what I want:
http://img.photobucket.com/albums/v190/baston/toaccent.gif
P.S. Acute accent is diacritical mark. Tag: How do I customize a toolbar for an addin template Tag: 105078
Printers
Is it possible to reference a Printer in vba by IP address?
I want to be able to change paper tray/bin dependant upon what type of
printer it is printing to but across the office the names of each printer
vary so wondered if i could refer to its ip address instead.
Many thanks for any help on this Tag: How do I customize a toolbar for an addin template Tag: 105076
hyperlinks in a paragraph
Anyone know how to insert hyperlinks in a blank word paragraph from .net -
Using vs2005SE and office 2007
I need to programatically replace parts of a paragraph with hyperlinks that
I know the texttodisplay and address of Tag: How do I customize a toolbar for an addin template Tag: 105063
How to make a new website with a link?
I can make a webpage in word, and then view it in internet, but the hyperlink
to get to it is always:
C:\Documents and Settings\All Users\Documents and so on and so forth.
How do you make that an actual link? Tag: How do I customize a toolbar for an addin template Tag: 105062
Security and VB References
I have a sales person who install Office 2007 on there computer. The quoting
software we use uses Word to create order forms. But I need to turn the
Security level to low and go into VB area and check the approraite dll files
under references.
I don't have 2007 and trying to talk over the phone to find them has been
interesting. I can't find the Security Area, I was able to get into the VB
area but the references are grayed out or not available.
So where is the secuity area and how can I make the references available?
Thanks..... Tag: How do I customize a toolbar for an addin template Tag: 105059
Using Distributed Link Tracking to fix Hyperlinks
Does anyone have references or experience with using Distributed Link
Tracking to fix hyperlinks to documents in your domain. This works for OLE
references and short cuts, but it appears not to work automatically for
hyperlinks.
--
Old Ed Tag: How do I customize a toolbar for an addin template Tag: 105055
Word VBA refernces to .tlb
I have a vs2007 project using created extensibility add-in for Word 2007. As
such I must load my dotm file, switch to developer/visual basic (ALT F11),
selected references, locate the .tlb file and add it. This all works fine as
does the .net code
The problem occurs (occasionally) as I make changes to the .net code.
Sometimes when I initiate the Word process, I will get a dialog box "could
not open macro storage".
When I start Word, load the .dotm file, ALT F11 to open VBA and check
references, I notice the .net project I am using is listed as missing. It
still has a check beside it. I uncheck to project, close references, open
references again, locate the project name (it is still in the available
refernces - just un checked), recheck the project, save and close the .dotm,
I am once again able to use word as expected with the addin functioning
correctly
This does not happen every time I change the project code. I often transfer
the solution and develop on other computers then transfer to solution back to
the original development computer. This effort always requires the dropping
of the project and then locate anc check it in VBA.
I expect this project to be in use for at least 5 years with many changes to
the code. I have worked out a deployment scheme that will auto deploy and
install the project as users login. The requirment to reload the reference in
VBA will be a problem.
Is there a registry change that I can record and push back during deployment?
Where is the information aboout loaded refences in VBA for Word maintained?
How can I inform Word (in an automated way) that the refernce to the .tlb
file is valid? Tag: How do I customize a toolbar for an addin template Tag: 105051
change font size of whole document
hello everyone
Ihave the following code to change font size.
Its not working.
Also, how do I deselect the text after executing the code.
Selection.WholeStory
If Selection.Font.Name = "Tahoma" Then
Selection.Font.Size = 15
End If
any help will be appreciated
thanx
ahmed Tag: How do I customize a toolbar for an addin template Tag: 105049
Userform Coding Problem that I need help with!
I'm hoping that someone can help me figure out a coding problem that I
SCREWED UP. I had this code in my Microsoft Word VB Editor that you see
below. The code worked PERFECTLY until I stupidly tried to edit it without
first making a backup. I know, first rule of any work is to make a backup, so
I can't believe I forgot to do that.
As an FYI, the "code" contained below was interfacing with one of my Excel
Workbooks, and allowed me to chose a client name from a dropdown menu (in
Excel), and when the name was chosen, Excel would call up a "Word", and the
Userform that was created would also open. This would then allow me to input
narrative comments into the Userform.
As a result of my "editing", I can select a client name (on the Excel
Workbook), but "Word" and "The Userform" no longer opens (actually it looks
as if it is trying to open, but cannot).
If some kind and knowledge person could look at the code below and let me
know if you see anything that I am leaving out I'd greatly appreciate it.
Dan
The Code in the MS Word Sample.doc VB Editor Module
Sub UpdateComments(parm1)
On Error Resume Next
Documents.Open FileName:=parm1
If Not FileExists(parm1) Then ' Check if file/folder exists .....
MsgBox "File " & parm1 & " does not exist", vbOKCancel
Exit Sub
End If
UserForm1.Show vbModeless
End Sub
_____________________________________________________________________
Function FileExists(fname) As Boolean
' Returns TRUE if the file exists
Dim x As String
x = Dir(fname)
If x <> "" Then FileExists = True _
Else FileExists = False
End Function Tag: How do I customize a toolbar for an addin template Tag: 105048
IF Field breaking bullets
Hello,
i'm have having a problem in Word 2003 for PC. When I create an IF field as
part of a bulleted list, the indent is correct but the bullet is removed. The
problem seems to be caused by the carriage return in the result of the IF
field. this causes the bullet to be removed on whichever line the field is
placed.
A few examples follow (? is the bullet point):
EXAMPLE 1
ï?§ Bullet 1
{ IF "T" = "T" "Bullet 2" "Bullet 3
ï?§ Bullet 4" }
ï?§ Bullet 5
Bullet 2,3 and 4 are being inserted by an IF Field and if the condition is
true then Bullet 2 is inserted, otherwise Bullet 3 and 4 are inserted.
RESULT 1
ï?§ Bullet 1
Bullet 2
ï?§ Bullet 5
however, the problem is that the bullet point for Bullet 2 is removed.
EXAMPLE 2
ï?§ Bullet 1
{ IF "T" = "F" "Bullet 2" "Bullet 3
ï?§ Bullet 4" }
ï?§ Bullet 5
notice that the IF field should display Bullet 3 and 4 now
RESULT 2
ï?§ Bullet 1
Bullet 3
ï?§ Bullet 4
ï?§ Bullet 5
in this case Bullet 4 was inserted correctly. but again no bullet for the
first one. the perplexing case is when the IF conditional field is inserted
after Bullet 1.
EXAMPLE 3
ï?§ Bullet 1{ IF "T" = "T" "
Bullet 2" "
Bullet 3
ï?§ Bullet 4" }
ï?§ Bullet 5
this should insert a hard return before Bullet 2. this results in:
RESULT 3
Bullet 1
ï?§ Bullet 2
ï?§ Bullet 5
any help would be appreciated
Andre' Tag: How do I customize a toolbar for an addin template Tag: 105043
searching a range
Can someone tell me what is wrong with this code? What I am trying to do, is
set a range to the first 5 sections of a document. Then I want to find a
particular string. If I find it, I want to clear that search and search for
something different. However, the search is not working (at all). It is
not finding the string that is actually in the document. (I tried changing
noticeplus.find to selection.find, which appeared to work. But as I got
deeper into the macro, I found that it was not doing what I wanted (It wasn't
just searching the range that I set, it was searching the entire document).
I know I have done this before and I know it is going to be something simple
and stupid, but it just has me stumped at the moment. Thanks for any help.
Dim noticeplus as range
Selection.HomeKey Unit:=wdStory
Set noticeplus =
ActiveDocument.Range(Start:=ActiveDocument.Sections(1).Range.Start,
End:=ActiveDocument.Sections(5).Range.End)
With noticeplus.Find
.ClearFormatting
.Text = "Electronic"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
End With
If noticeplus.Find.Execute("Electronic") = True Then
Selection.Collapse 1
Selection.HomeKey Unit:=wdStory
Set noticeplus =
ActiveDocument.Range(Start:=ActiveDocument.Sections(1).Range.Start,
End:=ActiveDocument.Sections(5).Range.End)
With noticeplus.Find
.ClearFormatting
.Text = "in accordance with your contract"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
End With
'Expert if
If noticeplus.Find.Execute = True Then
Selection.Collapse 1
Selection.HomeKey Unit:=wdStory Tag: How do I customize a toolbar for an addin template Tag: 105036
An alternative to "Forms"
Hi. I'm working with Vista and Word 2007. I'm trying to create some templates
for documents. I'd like to be able to have certain locations/spots within the
document that I can hit a key, quickly jump to and enter in some information,
then hit a key and jump to the next pre-designated location to enter in more
information. I realize that a "form" allows this, by tabbing. But it has two
problems:
1) It is cumbersome--I find that when I set up a form, from then on the
typing within it slows down to an excruciating pace, undoing the time-saving
of the quick jump.
2) Forms open in "protected" mode, and in my documents I will not only be
entering info in some spots, but I will be modifying info in other locations,
so I have to stop and "unprotect" after I've done the "form" part, and it
would be easier to just move through the document from top to bottom, jumping
to some spots, then stopping and modiying some info in others.
At a former workplace, Word had been modified so that when you hit "F9", it
would jump to some pre-set spot, which was designated in the template with
something like {ASK }. I don't know whether this was a macro with a field,
or what. But it met the need I described above--I could jump from spot to
spot, enter in new info, then make changes to some of the text that was
pre-set. Would anyone know how to achieve this in my current documents? I am
advanced at Word features, but not at all knowledgeable about programming.
Thanks.
dc Tag: How do I customize a toolbar for an addin template Tag: 105034
I need IS NOT (<>) operand for Font.Name
In the sub below I need to make line six return 'true' on any OTHER font that
the one listed. I've tried all the normal operands and nothing works.
The sub purpose is to replace all fonts with one single font.
Thanks,
Mike
Sub ReplaceFont()
With Selection.Find
' Clear all previously set formatting for Find dialog box.
.ClearFormatting
' Set font to Find for replacement.
.Font.Name = "Arial"
' Clear all previously set formatting for Replace dialog box.
.Replacement.ClearFormatting
' Set font to Replace found font.
.Replacement.Font.Name = "Times New Roman"
' Don't find or replace any text.
.Text = ""
.Replacement.Text = ""
' The following parameters must be set as follows
' to find only text formatted for the specified font.
' .Forward = True
' .Wrap = wdFindContinue
' .Format = True
' .MatchCase = False
' .MatchWholeWord = False
' .MatchWildcards = False
' .MatchSoundsLike = False
' .MatchAllWordForms = False
End With
' Perform the find and replace.
Selection.Find.Execute Replace:=wdReplaceAll
End Sub Tag: How do I customize a toolbar for an addin template Tag: 105031
read xml file with vba
i need to read the data in an xml file using vba to store the data in a
string. can anyone provide any code samples on doing this? Thanks in
advance. Tag: How do I customize a toolbar for an addin template Tag: 105030
Sequentially number multiple copies of a document IN DUPLICATE (NCR) using a macro
My apologies for the long subject line; it's essentially exactly what I am
looking for. I copied the example of the macro offered on the MVP site to
sequentially number a document and it worked perfectly-I've been tasked with
printing out 3,000 of them. The document will be used for Property
Management (inventory)control, but now they would like the form printed out
in duplicate, on carbonless copy paper. Is there a VBA string that I could
apply to the sequential numbering to duplicate a copy of each number?
Thanks very much in advance for any help with this. Tag: How do I customize a toolbar for an addin template Tag: 105024
disigning a form
I am designing a fill in document . i want some text fields like name to
automatically type into another text field in the latter of the same document
once filled in how do i do this? Tag: How do I customize a toolbar for an addin template Tag: 105020
How can I automatically determine a document idle time & close it
I need to write some vba code to determine a specific document's idle time
and if its more than 3 minutes it needs to save and close the document
without affecting other documents I might be working on. Tag: How do I customize a toolbar for an addin template Tag: 105016
Problems with Replace
Hello,
I'm a little bit new to Word VBA. Been working with Excel VBA for a while.
I built the following macro to delete text that had the style of
"Instructions" applied to it. The idea is for the user to execute this after
they're done filling out the document.
For the most part, it works well. There are a couple of problems however.
If the instructions are immediately followed by a table, inserted JPG, etc.
it doesn't delete the preceeding text. It could be a single space, a line of
text, whatever. The issue is when the text (styled with "Instructions")
immediately preceeds something WITHOUT a hard return, it doesn't get deleted.
Please give me some guidance. I appreciate your help.
Sub Test2()
Dim objDocumentRange As Range
Dim strTargetStyle As String
Dim strResultText As String
strTargetStyle = "Instructions"
strResultText = ""
Set objDocumentRange = ActiveDocument.Range
With objDocumentRange.Find
.Style = strTargetStyle
.MatchAllWordForms = True
.Text = strResultText
.Execute Replace:=wdReplaceAll
End With
End Sub
--
Programmer on Budget Tag: How do I customize a toolbar for an addin template Tag: 105002
Applying a paragraph style SOMEtimes wipes out bold/ital--why?
Hi all,
This is a very odd problem, much more easily explained with a sample file,
which I can email to you if you're interested.
Simply put, I'm applying a paragraph style in Word XP (2002) to various
paragraphs. The style does not apply or remove bold, italics, or underlines,
so I assumed it wouldn't affect those character styles when they're present
in the paragraphs I'm styling. Mostly, that's the case, but not always. Which
is very confusing to me!
There are three basic scenarios, and the third one does NOT act the way I
think it should:
1) I apply the style to a "Normal" paragraph with SOME bold or italics. As
expected, the bold and italics remain after the style has been applied.
2) I apply the style to a "Normal" paragraph that is ENTIRELY bold,
italicized, or both. Word XP seems to treat the bold/ital as a modification
of the "Normal" paragraph style ("Normal+Bold", say, for the whole para)
instead of being character styles. Therefore, the style I applies wipes out
the bold/ital. I guess I can see why that would happen.
3) This is the mystery. I have a row in a two-column table in which one cell
is entirely bold and one is not. I merge the two cells, then replace the
paragraph mark Word inserts with a tab, so it's all one paragraph. The
resulting paragraph consists of non-bold text, then a tab, then bold text.
Applying the style to this paragraph wipes out the bold. If I copy and paste
this paragraph outside the table, the same thing happens.
The end result is a sample file I can send in which there are two
paragraphs, one from scenario 1 and one from scenario 3. They both LOOK the
same--they're not bold until the last word. But applying the same style to
each causes bold to be kept in the first case and dropped in the second.
I know that scenario 3 is complicated, but I can't tell why the merging,
find-and-replace of the tab, etc. would cause that paragraph to behave
strangely.
Finally, to conclude this epic post, this is not limited to any particular
set of paragraphs--it happens consistently across many hundreds of pages of
material.
Anyway, the sample file is far easier to understand than this lengthy post,
so let me know if you want to see it.
Many thanks in advance--I'm afraid I really don't understand the "Paragraph
Style + Character Style" issues at all.
Ben Tag: How do I customize a toolbar for an addin template Tag: 105001
Is this possible or am I crazy?
Hi Everyone,
I work at a telephone call site. Currently we use a freeware program that
uses the Net Send command in conjunction with a database that allows us to
send instant pop up messages to individuals and preassigned groups of people.
The problem I am running into is that every time IT pushes out an update I
have to run around to apx 100 machines and reinstall the program. What I am
wondering is do any one think it would be possible to convert this to a web
page? I am a newbie to Front Page and know enough about Access to make me
dangerous. :) I do have a couple of Front Page books to help me if any one
thinks this project is even possible. What I visualize is a drop down box to
select recipients an input area for the message and a button when clicked
would send the message.
Any ideas would be greatly appreciated.
Have a GREAT day and weekend everyone!!!
Deb Tag: How do I customize a toolbar for an addin template Tag: 104999
"Save-as" to docm format
I placed the 'save as' command on my customize toolbar so I could select the
default format easily. I also set my default save option to the macro
enabled. When I click the customize dropdown and select the default file
type, it comes up as a .docx format. I am trying to automate this somewhat
to go through a whole series of files and I don't see a batch conversion
wizard.
--
Del Jackman
Civil Engineer
Mankato, MN Tag: How do I customize a toolbar for an addin template Tag: 104996
Convert footnotes to ordinary text
Hello,
I have a large document with several hundred footnotes. I'm looking
for a code to replace the footnote reference with the actual footnote
text. Any ideas on where to start?
--
Fredrik E. Nilsen Tag: How do I customize a toolbar for an addin template Tag: 104991
Missing ComboBox Combination
Hello
I have a User form created is VBA
I have a combo box and it does not work below are all the codes for this
combobox
Private Sub ComboBox2_Change()
' enter value to unload combo box 2
ActiveDocument.FormFields("Text84").Result = ComboBox2.Value
Private Sub UserForm_Initialize()
ComboBox1.ColumnCount = 1
'Load data into ComboBox
ComboBox1.List() = Array("offer", "renew")
ComboBox2.List() = Array("New", "Expired", "Scheduled to Expire")
ComboBox3.List() = Array("Pricing Specialist", "Senior Pricing Specialist")
End Sub
Private Sub CommandButton1_Click()
With ActiveDocument
.Bookmarks("Text71").Range _
.InsertBefore TextBox1
.Bookmarks("Text72").Range _
.InsertBefore TextBox2
.Bookmarks("Text84").Range _
.InsertBefore ComboBox2
.End With
UserForm1.Hide
When I test the form and I get to the comboBox2 and I select an option I get
the error message
Run-Time error "5941':
The requested member of the collection does not exist.
when I click debug the following is highlighted
Private Sub ComboBox2_Change()
' enter value to unload combo box 2
ActiveDocument.FormFields("Text84").Result = ComboBox2.Value
Please How do I correct this? I have tried to no avail thanks Tag: How do I customize a toolbar for an addin template Tag: 104990
Master -Sub documents
Hi
I am trying to create a set of master/subdocuments. The source files are on
my network drive.
I create the first document, and then goto Outline and insert a subdocument.
However when i view this is appearing as a link rather than displaying the
doucment itself.
if I do the same on my laptop, i can see the subdocument.
Can someone tell me what I'm doing wrong?
Thanks
Alexey Tag: How do I customize a toolbar for an addin template Tag: 104985
I've just created a few macros and now I'd like to create a toolbar to go
along with it. This seemed very simple in 2003, but I'm having trouble
creating one in 2007.