Header and Footer StoryRanges
Does anyone know why shapes in the header or footer story ranges are treated
differently than shapes contained in the main text story?
If I put two shapes containing text (text containing one spelling error) in
the main text story and two shapes containing similar text in the header of
a document and run this code:
Sub CheckForErrors1()
Dim pRange As Word.Range
Dim oShp As Shape
Dim i As Long
For Each pRange In ActiveDocument.StoryRanges
Do
i = i + pRange.SpellingErrors.Count
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
MsgBox i
End Sub
This msgbox response is 2.
The correct response should be 4 which is the results of running this code:
Sub CheckForErrors2()
Dim pRange As Word.Range
Dim oShp As Shape
Dim i As Long
For Each pRange In ActiveDocument.StoryRanges
Do
Select Case pRange.StoryType
Case 6, 7, 8, 9, 10, 11
i = i + pRange.SpellingErrors.Count
If pRange.ShapeRange.Count > 0 Then
For Each oShp In pRange.ShapeRange
If oShp.TextFrame.HasText Then
i = i + oShp.TextFrame.TextRange.SpellingErrors.Count
End If
Next oShp
End If
Case Else
i = i + pRange.SpellingErrors.Count
End Select
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
MsgBox i
End Sub
Why do shapes in storyrange type 6, 7, 8, 9, 10 and 11 have to be treated
separately and individually?
Thanks.
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word. Tag: Merge 2 Word XML Files Tag: 108152
Variance in word count
Hi All
I have an ordinary document where if I look at File - Properties - Stats, my
wordcount is 256. This agrees with Tools -WordCount.
In VB I execute x = ActiveDocument.Words.Count and x is 331.
256 is the correct word count.
Can anyone explain how x becomes 331. It's not counting spaces because I
have 244 of them, and I'm showing hidden text.
Can VBA get the count from "File - Properties - stats" figure?
TIA
Ian B Tag: Merge 2 Word XML Files Tag: 108128
Need program to convert plain text in doc into Word 2007 para
Has anyone written a program that will scan through a word document that
contains pasted plain text and removes the paragraph that is at the end of
multi-line paragraphs? When I cut and paste from a plain text document into
word, I get line lengths on each line that are determined by a paragrah mark
(no word wrap).
I've scoured the forums and help files & it appears that Word versions prior
to 2007 had an autoformat feature that would do something like this.
However, Word 2007 dropped that feature. I'm not a Word programmer. Can
someone help with this?
--
Thanks
Dave Tag: Merge 2 Word XML Files Tag: 108126
Error if macro "Run", No error if single stepped! Help?
It was a reliable piece of code, and stuff around it has changed but the key
point is that if I "Run" the macro (which copies from a bookmark in one doc
and pastes the text into another) the pastespecial fails (empty clipboard),
but if I single step through the code it all works perfectly (NB I have
over-ridden the Ctrl-V keyboard shortcut for paste, but what should that
have to do with it?).
I removed all the modules from Normal.dot and then re-imported them (not
sure if I quit in-between though) but on this occasion it made no
difference... have I missed a trick?
Ideas?
TIA
Julian Tag: Merge 2 Word XML Files Tag: 108117
if Error, Pause or Loop
Is there a way to, If Error then loop back and try again.
This is a live file which is connected to my file and I have it save every
13 seconds but if the live link is saving, it errors out.
'/////////////////////////////////////////////////
Sub UpdateLinks()
ActiveWorkbook.UpdateLink Name:= _
"\\DTCNAS-ILSP002\Tesing\LiveLink.xls" _
, Type:=xlExcelLinks
Range("A1").Select
Call UpdateTime
End Sub
Sub UpdateTime()
Application.OnTime Now + TimeValue("00:00:13"), "UpdateLinks"
End Sub
--
ca1358 Tag: Merge 2 Word XML Files Tag: 108114
Starting MSWord Merge from MSAccess
I am collecting info from an MSAccess record and trying to merge it in Word.
I would like this to work with any version of Word that the user may have
installed. My MSAccess app will be a runtime app that I will be putting on
various machines in different workplaces.
Here is the code I am running from MSAccess:
Public Function AddressBlock() As Boolean
Dim wd As Object
Dim wdActiveDoc As Object 'RM: Added this to help ensure that you're
'working on the document you intend to.
Dim wdField As Object 'RM: Note the change in name here to avoid
'ambiguity with the Field object in both Word and
'Access. As well, I changed the type, since
'(like Word.Application), you have to use late
'binding.
Set wd = CreateObject("Word.Application")
wd.Visible = True
wd.Application.ScreenUpdating = False
Set wdActiveDoc = wd.Documents.Open("K:\legalper\merge_ad.doc ", False,
False, _
False, "", "", False, "", "", 0)
With wdActiveDoc.MailMerge
.Destination = 0
.Execute
End With
wd.Windows("merge_ad.doc ").Activate
wd.ActiveWindow.Close 0
'It bombs here with "Automation error: The object invoked has disconnected
from its clients", and the next line is highlighted.
'What I'm trying to do here is open merge_ad.doc, merge it, close
merge_ad.doc, then save the
'resulting merged doc as "merged_ad.doc"
wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc", FileFormat:=0
Thanks in advance,
Kathy Tag: Merge 2 Word XML Files Tag: 108110
Link to external graphic file or insert/delete graphic
I have a macro which I use to toggle certain graphics on or off. I have
inserted the relevant piece of code below. The problem is that all my
documents have mushroomed to 800+ kb in size from 40kb previously.
My question is it possible to link to a graphic based in a permanent
location rather than the graphic residing in each document? If not, is it
possible to insert the file and delete it instead of toglling visible/hidden?
I would need the graphic to be a precise size and at a precise location.
Thanks.
The current code is:
With ActiveDocument
' Check current status - it's in fax format if graphics are visible
boolFax =
.Sections(1).Headers(wdHeaderFooterFirstPage).Shapes(1).Visible
' Show/Hide the graphics
With .Sections(1)
For Each aShape In .Headers(wdHeaderFooterFirstPage).Shapes
aShape.Visible = Not boolFax
Next aShape
End With Tag: Merge 2 Word XML Files Tag: 108103
Evaluating the previous and following character in a Search and Replace
Hi all,
Is there a way to evaluate the character before and after the found string in a routine like this:
With rTmp.Find
.ClearFormatting
.Text = var1
.MatchWholeWord = True
.MatchWildcards = False
'evaluate character here?
.Replacement.ClearFormatting
.Replacement.Text = var2
.Execute Replace:=wdReplaceAll
End With
Something like:
If 'prevous charecter is a tab or a carriage return or ". " Then
'use a capital for the first character in the replacement string
Else 'use no initial capital in the replacement string
End If
Best regards,
Shirley Tag: Merge 2 Word XML Files Tag: 108102
icon message box
I have created a macro that shows a dialog box with all my installed
printers where I work. My question is if there is any way to have the macro
icon's yellow message box show the name of the currently selected printer
when the user hovers the mouse over it? This would be similar to what now
happens when I hover my mouse above the printer icon in Word. How would I go
about controlling the message box for an macro's icon?
TIA,
Art® Tag: Merge 2 Word XML Files Tag: 108100
UserForms to Populate FormFields
I would like to use UserForms to Populate formfields rather then bookmarks is
ths Possible? or is there a way for the bookmaks to hold a specific section
of a document without disturbing the rest?
With ActiveDocument
.Bookmarks("tklarm1").Range _
.InsertBefore TextBox1
.Bookmarks("tklarm2").Range _
.InsertBefore TextBox2
End With
UserForm14.Hide Tag: Merge 2 Word XML Files Tag: 108092
Search and replace predefined sets of strings?
Dear all,
I need to build a code to search a predefined set of strings in a document and replace them by another predefined set of strings.
Example:
strS is (vssen | vsen | vss | vss. | vs. | vs | v. | v )
strR is (vÿerÿssen | vÿerÿsen | etcetera...)
strS (search strings) and strR (replacement strings) have the same number of elements. The first element of strS should be replaced by the first element of strR, etcetera, but
1) how do I set a string variable to a limited list of search/replacement strings. Would that be an array? and
2) why does the .HighlightColorIndex = wdNoHighlight not compile in my first attempt (see below)?
Sub Vop()
Dim rTmp As Range
Set rTmp = ActiveDocument.Range
'declare variables for search and replace texts
Dim strS, strR As String
Dim lngC As Long
'for loop to execute F&R with all strings
With rTmp.Find
.Text = strS
.Replacement.Text = strR
'add .HighlightColorIndex = wdNoHighlight -> does not compile
.MatchWholeWord = True
.MatchCase = False
.MatchWildcards = False
While .Execute
rTmp.start = rTmp.End
rTmp.End = ActiveDocument.Range.End
Wend
End With
End Sub
Best regards - Shirley Nomey Tag: Merge 2 Word XML Files Tag: 108089
Inserting images into a table, Having trouble inserting in next ce
Hi,
I am using late binding and trying to insert e.g. 9 images into a table
(3x3) in Word.
I am having trouble moving to the next cell; VB throws an error on
'wrdSelection.moveright 'Unit:=wdCell' - 'Bad command'. Are there any
specific constants for wdCell or not?
code extract:
---------------
Dim WrdApp As Object
Dim WrdDoc As Object
Set WrdApp = CreateObject("Word.Application")
Dim wrdSelection As Object
Set wrdSelection = WrdApp.Selection
Dim sPic As Object
...
'1st Pic
Set sPic = WrdDoc.InlineShapes.AddPicture(FileName:="C:\1.jpg",
LinkToFile:=False, SaveWithDocument:=True)
'Move on 1 column
wrdSelection.moveright
wrdSelection.moveright
'wrdSelection.moveright 'Unit:=wdCell, Count:=1, Extend:=wdMove 'wdCell
throws err msg 'Bad Command'
'WrdDoc.tables(1).Cell(2, 1).Range.Select ' just selects the column but does
not affect next image insert
'2nd Pic
Set sPic = WrdDoc.InlineShapes.AddPicture(FileName:="C:\1.jpg",
LinkToFile:=False, SaveWithDocument:=True)
....
Thanks any help would be greatly appreciated!
Cheers,
Hendrik Tag: Merge 2 Word XML Files Tag: 108082
I need a macro to search across multiple files
Hello,
I need to do search and replace across multiple doc files, and be prompted
before each replace. Is there such a utility, macro? Thank you.
T.I. Tag: Merge 2 Word XML Files Tag: 108078
Add to listbox with multiple columns
Using an Access Form with two listboxes... List1 and list2 with two columns
in each list. when I click an item in list1 I want the data on that row to go
into list2 with the columns reversed.
IndexNum = 0
List1.column(1, List1.Listindex) into List2.column(0, IndexNum) &
List1.column(0, List1.Listindex) into List2.column(1, IndexNum)
I can enter List1.column(1, Listi.listindex) into the first column of List2
but do not know how to enter data into the second column of List2.
Any ideas? Tag: Merge 2 Word XML Files Tag: 108076
acces & word
I have to fill documents from tables in access.
Actually i have 3 choices:
1. Mailmerge in vb with the tables field
2. using a routine replacing all the parts i need using numbers like 1____
and 2_____ and so on
So i can do a for next replacing the index & "_" using find
(.MatchWildcards and so on)
3. using bookmarks and replacing them
What do you suggest me as best solution? Tag: Merge 2 Word XML Files Tag: 108062
Insert Bullet and Text
Hi,
Below is userform code im working on and I believe im close .. but just
can't seem to get it to work. I know my code isint proffesional at all, but
I hope you get the idea of what I was doing.
Code Objective: Open a document which contains a table , search col1 for the
word that matches a textbox in the userform (which becomes the target row)
then depending on what the user selects in the dropdown deteminds the target
Col to add a bullet to the list.
*Note opening the doc and every thing works just not the inserting a bullet
Thank you to anyone that helps.
Happy Holidays!
Ben Z.
CODE:
Private Sub CommandButton1_Click()
'Works with custom toolbar
Dim sendbar As CommandBar
Dim sendbox As CommandBarControl
Set sendbar = Application.CommandBars("Todays-Task")
Set sendbox = sendbar.Controls(2)
Set sendtopic = sendbar.Controls(1)
Dim Word As New Word.Application
Dim WordDoc As New Word.Document
Word.Visible = True 'Only true during testing'
Dim strPath As String
'Open word doc'
C = ActiveDocument.CustomDocumentProperties("Task").Value
strPath = "C:\MyDocuments\" & T & "\Planning\2007\Todos.doc"
Set WordDoc = Word.Documents.Open(strPath)
With WordDoc
System.Cursor = wdCursorWait
Dim oTbl As Table
Dim oCll As Cell
'<><><><><>Search Col(1) For Keyword<><><><><><><>'
Set oTbl = WordDoc.Tables(1)
With oTbl
For Each oCll In .Columns(1).Cells
If oCll.Range.Text = sendtopic.Text Then
p = oCll.RowIndex
End If
Exit For
Next
End With
'<><><><> Based on userform info<><><>'
If ComboBox2.Text = "Pay" Then
Set oTbl = WordDoc.Tables(1)
Set Selec = oTbl.Cell(p, 4)
With Selec
.EndOf Unit:=wdCell
.TypeText Text:=sendbox.Text
End With
WordDoc.SAVE
WordDoc.Application.Quit
System.Cursor = wdCursorNormal
MsgBox "Task Updated"
End Sub Tag: Merge 2 Word XML Files Tag: 108061
Bold a list of words in a given document
Hi,
I have a list of words in a doc say List.doc where I have listed a number of
words one below the other like:
Microsoft Word
SAP
E-business Suite
Salesforce.com
Iam currently using the below mentioned macro:
Sub Mymacro()
Dim sCheckDoc As String
Dim docRef As Document
Dim docCurrent As Document
Dim wrdRef As Object
sCheckDoc = "D:\List.doc"
Set docCurrent = Selection.Document
Set docRef = Documents.Open(sCheckDoc)
docCurrent.Activate
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Font.Bold = True
.Replacement.Text = "^&"
.Forward = True
.Format = True
.MatchWholeWord = True
.MatchCase = False
.MatchWildcards = False
End With
For Each wrdRef In docRef.Words
If Asc(Left(wrdRef, 1)) > 32 Then
With Selection.Find
.Wrap = wdFindContinue
.Text = wrdRef
.Execute Replace:=wdReplaceAll
End With
End If
Next wrdRef
docRef.Close
docCurrent.Activate
End Sub
The problem here is that when I run this macro in another document having
these terms it does runs but BOLDS the letters "Microsoft", "Word", "E",
"Business", "Suite", "Salesforce" ".com" separately along with the full
letters i.e., Microsoft Word, E-business Suite, Salesforce.com.
I want only the full letters to be bolded. Kindly help me out in this.
Thanks,
Prashanth KR. Tag: Merge 2 Word XML Files Tag: 108060
Temperature conversion macro
I am trying to write a macro which searches through a document for a
temperature value such as 395 °F and will convert it to celcius and display
both values in the format 395 °F (xxx °C). I have tried all sorts of things
and cannot get the code to find the temperature values and process it. Does
anyone have any suggestions?
Public Sub macro4()
Dim oRg As Range
Set oRg = ActiveDocument.Range
Dim sText
With oRg.Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
.MatchWildcards = True
.Text = ("[0-9]{1-4} °F")
.Forward = True
.Wrap = wdFindContinue
Do While .Execute
oRg.Text = ((5 / 9) * ((Left(oRg.Text, Len(oRg.Text) - 3)) - 32))
oRg.Collapse Direction:=wdCollapseEnd
Loop
End With
End Sub
This code works if I have it find a specifc value, but not if I use the
[0-9]{1-4} values. Also, my output does not put it in the format I specified
above, I just want to get it to work first. Also, I would like the output to
be no more than one decimal place.
Thanks for the help Tag: Merge 2 Word XML Files Tag: 108057
VB.Net Word Automation
Can anyone tell me why I am getting a blank page in my word document using
the code below? I have a checklistbox on my form and for each checked item I
want the same amount of pages in my word document. For instance, 3 items
checked = 3 MS Word pages but its giving me 4 pages instead with the second
page in the document being blank. As you can see below I am not necessarily
using the VSTO add-in for VS Pro but I figured someone here would be able to
point something out to help. Thanks in advance. I hope that made sense.
Anyway here is my code:
Dim dt As DataTable
dt = XSdSponsor.GetData()
Dim wdApp As New Word.Application
wdApp.Visible = True
wdApp.Documents.Open("d:\testing.doc")
Dim pagebreak As Object = Word.WdBreakType.wdPageBreak
Dim checked_items As CheckedListBox.CheckedItemCollection
checked_items = cboMailMerge.CheckedItems
Dim item As Object
Dim bVal As Boolean = True
Dim Rng As Word.Range
For Each item In checked_items
Dim str As String = item.ToString()
For i As Integer = 0 To dt.Rows.Count - 1
If dt.Rows(i)("orgName").ToString() = str Then
Dim rng1 As Word.Range =
wdApp.ActiveDocument.Bookmarks("ContactName1").Range()
Dim rng2 As Word.Range =
wdApp.ActiveDocument.Bookmarks("CompanyName").Range()
Dim rng3 As Word.Range =
wdApp.ActiveDocument.Bookmarks("StreetAddress").Range()
Dim rng4 As Word.Range =
wdApp.ActiveDocument.Bookmarks("City").Range()
Dim rng5 As Word.Range =
wdApp.ActiveDocument.Bookmarks("State").Range()
Dim rng6 As Word.Range =
wdApp.ActiveDocument.Bookmarks("ZipCode").Range()
Dim rng7 As Word.Range =
wdApp.ActiveDocument.Bookmarks("ContactName").Range()
Dim rng8 As Word.Range =
wdApp.ActiveDocument.Bookmarks("EventName").Range()
If bVal = True Then
rng1.Text = dt.Rows(i)("orgFname").ToString() & " "
& dt.Rows(i)("orgLname").ToString()
rng2.Text = dt.Rows(i)("orgName").ToString()
rng3.Text = dt.Rows(i)("orgSaddress").ToString()
rng4.Text = dt.Rows(i)("orgCity").ToString()
rng5.Text = dt.Rows(i)("orgState").ToString()
rng6.Text = dt.Rows(i)("orgZipcode").ToString()
rng7.Text = dt.Rows(i)("orgFname").ToString() & " "
& dt.Rows(i)("orgLname").ToString()
rng8.Text = dt.Rows(i)("ReqEvent").ToString()
Else
Rng =
wdApp.ActiveWindow.Selection.Bookmarks("\page").Range()
Rng.Select()
Rng.Document.ActiveWindow.Selection.Copy()
Rng.Select()
Rng.Collapse(Word.WdCollapseDirection.wdCollapseEnd)
Rng.Select()
Rng.InsertBreak(pagebreak)
Rng.Paste()
rng1.Text = dt.Rows(i)("orgFname").ToString() & " "
& dt.Rows(i)("orgLname").ToString()
rng2.Text = dt.Rows(i)("orgName").ToString()
rng3.Text = dt.Rows(i)("orgSaddress").ToString()
rng4.Text = dt.Rows(i)("orgCity").ToString()
rng5.Text = dt.Rows(i)("orgState").ToString()
rng6.Text = dt.Rows(i)("orgZipcode").ToString()
rng7.Text = dt.Rows(i)("orgFname").ToString() & " "
& dt.Rows(i)("orgLname").ToString()
rng8.Text = dt.Rows(i)("ReqEvent").ToString()
End If
wdApp.ActiveDocument.Bookmarks.Add("ContactName1",
CType(rng1, Word.Range))
wdApp.ActiveDocument.Bookmarks.Add("CompanyName",
CType(rng2, Word.Range))
wdApp.ActiveDocument.Bookmarks.Add("StreetAddress",
CType(rng3, Word.Range))
wdApp.ActiveDocument.Bookmarks.Add("City", CType(rng4,
Word.Range))
wdApp.ActiveDocument.Bookmarks.Add("State", CType(rng5,
Word.Range))
wdApp.ActiveDocument.Bookmarks.Add("ZipCode",
CType(rng6, Word.Range))
wdApp.ActiveDocument.Bookmarks.Add("ContactName",
CType(rng7, Word.Range))
wdApp.ActiveDocument.Bookmarks.Add("EventName",
CType(rng8, Word.Range))
bVal = False
Exit For
End If
Next
Next item Tag: Merge 2 Word XML Files Tag: 108041
Can't exit design mode because Control 'TextBox' cannot be created
I get the following VBA message when I try to switch from the design mode of
a text box in a Word document:
Can't exit design mode because Control 'TextBox' cannot be created
I initially inserted a text box from the control toolbox in word and was
able to input text. Upon opening the document later, Word converted the
textbox into a picture. I receive the above message when I click on this
picture and try to bring it out of design mode.
support.microsoft.com recognizes this as a bug, but refers to this problem
only in the context of when a control toolbox is added to the normal
template, not to a regular document.
Any ideas? Thanks in advance. Tag: Merge 2 Word XML Files Tag: 108040
Nested If result based on combo box value
I've been trying to figure out (with no luck) a way to return a string
value to a text box based on a result from a combo box.
To try and keep it simple:
If Combobox = Value.A then textbox.value = Result.A
If Combobox = Value.B then textbox.value = Result.B
If Combobox = Value.C then textbox.value = Result C
I tried to do a select case but i obviously had the syntax wrong.
Any assistance is kindly appreciated. Tag: Merge 2 Word XML Files Tag: 108036
PDF Documents in WORD list
Why does a PDF document not show up on my WORD 2002 list of documents?
It shows up if I go to Windows Explorer and open the file that has all of my
documents, but NOT if I just click on WORD - file - open - My Documents.
I'm using Windows XP Home with SP2.
Thanks in advance for any suggestions. Tag: Merge 2 Word XML Files Tag: 108033
using word as a WScript object
I have a script that uses word as an object runs it with a certain file open
and then prints it, however, it does not print in color. Can anyone tell me
how to set an option to print in color?
The script that prints with no color:
Set app = Wscript.CreateObject("Word.Application")
app.Documents.Open("\\\server\share\document.doc")
app.Options.PrintBackground = False
app.ActiveDocument.PrintOut: Tag: Merge 2 Word XML Files Tag: 108031
new idea
To microsoft Company
The security of trading via internet is considerably crucial and
professional fishers and hackers are just waiting for mis using the mistakes
maden by the users and discharging their electronic accounts.
I'm Mr.Ali Noor Mohammadi from Iran.I have a plan that to a great extent
ensures the security of user name and password of the users from being
misused by the fishers and hackers.
Regarding that i can't launch this plan to the net and necessarily the
implimentation of that can only be done by large companies , specially by the
companies that are active in designing and launching the operation systems
made me to write to you about the implementation of that. I do know that your
company is the most advanced in this field.
1-The income from the increase in reliability of credit cards such as visa
and master card , etc.
2- the income from the monthly or annual payment of the companies that are
active in the fields of purchasing and selling , for the increasing security
coefficient of users.
3-getting control over the security market.
At the end regarding what i mentioned above , please let me know if you
want to cooperate.
khoshtip118@gmail.com
----------------
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=df8f06e7-6754-427b-850d-476bd5a20bf6&dg=microsoft.public.word.vba.general Tag: Merge 2 Word XML Files Tag: 108029
What is the best way to read Word text looking for patterns?
Hi All
I have a file system full of Word documents. All the documents have
identifiers that follow a proscribed form :
CJS/<number>/<number>
e.g. CJS/10/1023 and CJS/10/2023
I need to find which documents reference other documents in their body
text.
I am an intermediate Excel VB programmer and hope to do this in Word
VB with the following pseudo-code for a single document:
* open the document
* read the text in some fashion in some sort of chunk per
iteration
* scan this text for text that looks like the above described
document number pattern
* compile the list as I go and output to Excel
Is this all possible in Word VB? It seems to me the trickest part
would be to work out how to read the text in......
Does anyone have any hints or ideas to get me started on this one? I
have the code to open a Word file but that is it at this time. What is
the best way to read the text from a Word document into a VB program?
Thanks for any ideas.
Chrisso Tag: Merge 2 Word XML Files Tag: 108028
What is the best way to read Word text looking for patterns?
Hi All
I have a file system full of Word documents.. All the documents have
identifiers that follow a proscribed form :
CJS/<number>/<number>
e.g. CJS/10/1023 and CJS/10/2023
I need to find which documents reference other documents in their
text. I am an intermediate Excel VB programmer and hope to do this in
Word VB with the following pseudo-code for a single document:
* open the document
* read the text in some fashion in some sort of chunk per
iteration
* scan this text for text that looks like the above described
document number pattern
* compile the list as I go and output to Excel
Is this all possible in Word VB? It seems to me the trickest part
would be to work out how to read the text in......
Does anyone have any hints or ideas to get me started on this one? I
have the code to open a Word file but that is it at this time. What is
the best way to read the text from a Word document into a VB program?
Thanks for any ideas.
Chrisso Tag: Merge 2 Word XML Files Tag: 108023
Turn off replacement status indicator when running a VBA macro
I created a word macro (word 2003, windows XP) that uses replace to get rid
of space characters in tables. Some of these tables are large and there are
a lot of replacements. A replacement status indicator shows up at the bottom
of the word pane which greatly slows the execution of the macro. I have
tried turning off screen updating, alerts, status bar and cannot make it go
away. Does anyone know how to stop displaying this indicator? It also shows
repagination status if that's any help. Tag: Merge 2 Word XML Files Tag: 108017
VBA to delete a row based on rows being filled.
Here is my code. I move information from one sheet to another. This
part works fine. I then woudl like to delete rows if there is nothing
in columns J, M, S, and V. Someone had given me the code to go
through the sheet. Hopefully someone can help me.
Jay
Sub Offset()
Dim myCount As Integer
Dim NextRow As Long
Dim Datei As Date
Datei = Range("E1")
Range("A7:C26, V7:Am26, Bm7:Bp26").Copy
Application.ScreenUpdating = False
Workbooks.Open Filename:="G:\DPE-IPE\DPE REVISIONS\All Press Ips.xls"
NextRow = Range("D65536").End(xlUp).Row + 1
Sheets("Offset").Range("D" & NextRow).PasteSpecial
Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Dim i As Long
With Sheets("Offset")
' Loop through the rows
For i = 1 To .Cells.SpecialCells(xlCellTypeLastCell).Row
' Test cells in columns J, M, S &V
If .Cells(i, 10).Value = "0" And .Cells(i, 13).Value = "0"
And .Cells(i, 19).Value = "0" _
And .Cells(i, 22).Value = "0" Then .Cells(i,
1).EntireRow.Delete
Next i
End With
End Sub Tag: Merge 2 Word XML Files Tag: 108008
Location of incorrect place in the incorrect xml file
Hi All,
I am programming in VBA for Word and use Microsoft XML v6,0 xml library for
working with xml files.
Sometimes xml files are incorrect and xml parser does not create node
structure for such files.
I need to know line in the xml file there is error is present.
Error can be:
1. Unclosed tag.
2. Merged tags as : <tag1><tag2>Some text<tag1><tag2>.
3. e.t.c.
May be anybody know how to get such information from MSXML or other library
included in the Office package or Windows?
May be any free library is present for it that can be used from macro?
Thank you,
Anton Tag: Merge 2 Word XML Files Tag: 108005
Custom rules for words to not spell check
Is there any way that I can tell Word not to
not spell check words starting with $?
Motivation: I'm writing a document in
Word 2003 / Win XP Pro, which document has
PHP computer code interspersed. Variable
names are uniformly indicated by a dollar
sign ($) prefixing the variable name
(eg. $myVar). These should be ignored for
purposes of spell checking.
I noticed that under
Tools \ Spelling and Grammar \ Options
there is the possibility to ignore words
in UPPERCASE and words with numbers. So I'm
asking can I, possibly with VBA, expand upon
this?
Thanks,
Csaba Gabor from Vienna Tag: Merge 2 Word XML Files Tag: 108004
How to read/Encrypt Word Document without opening document?
Hi,
I want to read/Encrypt word document withour opening the document through
Ole or oleload. I am able to get document properties using structred storage
but not able to read/Encrypt data without opening document?
SSD Tag: Merge 2 Word XML Files Tag: 108001
Delete or reset values for all custom document properties
As part of an automated document cleanup process, I created a VBA userform
that lets the user select up to 14 kinds of things to be removed from a Word
document (tracked changes, comments, hidden text, etc.) This is kind of an
ersatz Remove Hidden Data tool.
I would like to be able to include in this form the option to remove any
custom document properties that have been set in a Word document before we
send the document outside the office. We sometimes send many dozens of files
at once and each may have many custom document properties set for it. We have
received files from outside the office that contained custom document
properties that I know the sender would not have wanted us to see and I want
to make sure we avoid that same problem.
The problem is I can't find a way to automatically remove all custom
properties. These can be of two kinds: the custom document properties that
are already in the document (from the template - I can manually delete the
value but the name remains) and those created by document users (I can
manually delete both the property name and the value for these). While it is
quite easy to add new custom document properties and property values with
VBA, I cannot find a way to automatically delete all custom document
properties or their values. I can automatically remove the values for those
custom document properties that are in the template (since I know each
property's name) but I cannot find a way to delete or at least remove the
value for a custom property created by a user. It would be sufficient for me
to reset the value of a user-created custom document property to no data or a
space or some other text, but I have been unable to get anything to work.
Although just removing the value might leave the user-created custom property
name visible in the document properties, at least the value would be gone. At
this point, I don't need to choose to keep any custom document properties. It
appears that it will be sufficient to just remove all and I don't need the
option to preserve some of the custom properties for the files we send out. I
have searched several groups and through the VBA help but can't find a
solution. I would appreciate help with some VBA code that would handle all
the custom document properties. Thanks. Tag: Merge 2 Word XML Files Tag: 107996
converting a file
Have a rtf file saved as a word.doc no good for locate. No matter how I try
to use this file code will not locate file. Is there a way to convert this
file so it is a reconizable word.dco? It opens with word ok. I am useing
office 2000.
Thanks Tag: Merge 2 Word XML Files Tag: 107995
Delete Rows based on information in column
I had asked for help on another Group, I think i am in the right one
now. I have copied info from one workbook to another. Now that it is
here, I need to delete the entire row if the cells in columns J, M, S
and V are empty. All fo the cells need to be empty inorder for the
row to be deleted.
Thanks in advance,
Jay Tag: Merge 2 Word XML Files Tag: 107992
Macro to resize and center align pictures, charts, canvas in MS Word
Hey people,
I am novice to word VBA programming.
I have a word document and it contains, pictures, charts and canvas
(powerpoint slides).
Currently, I use the following code to center align the pictures and
charts.
Sub test()
Dim dc As Document
Dim ilShp As InlineShape
Set dc = ActiveDocument
For Each ilShp In dc.InlineShapes
If Not ilShp.Type = wdInlineShapeOLEControlObject Then
ilShp.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
End If
Next
End Sub
I trying to write macros to:
1. Center align a canvas
2. Strecth/resize a picture to fit the width of the page while
mainitaing the aspect ratio.
Please let me know the macro for those.
I would really appreciate any help. Thank You. Tag: Merge 2 Word XML Files Tag: 107982
Word 2007 Calling the 'Add-ins' tab.
I have written a routine which involves the creation of a new toolbar
(commandbar). In Word2003 and before, the command bar appears 'in your face'
among the other toolbars at the top of the screen. This is good.
When the same macro is run in Word2007, it hides behind the 'Add-ins' tab at
the top of the screen. (This is so even though I may set it to 'floating'.)
There, the command bar is apparent to noone and therefore virtually
worthless.
Is there VBA code that can automatically call the Word 2007 Add-ins tab at
the end of a VBA module so that the user will be able to see the change and
the availability of the new toolbar?
Ed (in Virginia) Tag: Merge 2 Word XML Files Tag: 107980
How to send user to a particular part of a Word document from
Hi All
I have a manuals for my systems in Word. At various places around my
Access and Excel systems I would like to place help icons - when the
user clicks these my VB will not only open the document but open it to
the correct heading/page that discusses the feature near the help icon
pressed.
I have found on these boards code to open the Word document. Does
anyone know the VB for then setting the users screen to a particular
part of the document? I have not tried any Word VB programming yet so
I am hoping someone out there has this sort of code lying around.
Cheers for any help,
Chrisso Tag: Merge 2 Word XML Files Tag: 107976
Word 2003 read rtf file into textbox
Hi,
Is there a way to read a .rtf file into a textbox
I only would like te read the text without the format, without
actually opening the file.
thanx
Jans Tag: Merge 2 Word XML Files Tag: 107973
Combo Box without form protection Word 2003
Hi everyone
I want to add a number of combo boxes to my document but I can't have form
protection turned on as the document is used by MS Navision as a template,
which won't work with any protection turned on. I tried using form
protection on just a section of the document, but this doesn't seem to be
possible.
Also, I only want the contents of the combo box to be printed (i.e. not the
combo-box itself).
Can anyone tell me if this is possible?
Thanks
Rebecca Tag: Merge 2 Word XML Files Tag: 107970
How to automatically create missing subdocuments ?
Hi,
I Have a word document that is automatically generated by an application.
This document refers to subdocuments but some of them are (sometime)
missing.
I'd like to write a vba macro which will check all subdocuments and will
create the missing ones.
The following code does not work:
Sub createMissingSubDocuments()
For Each sd In ActiveDocument.Subdocuments
file_path = sd.Path & Application.PathSeparator & sd.Name
If sd.HasFile = True Then
'MsgBox subdoc.Path & Application.PathSeparator & subdoc.Name
Else
Documents.Add.SaveAs FileName:=file_path,
fileformat:=wdFormatRTF
End If
Next
End Sub
When reaching Documents.Add.saveAs ... an error is raised saying that
the file already exists (but actually it does not exist) Tag: Merge 2 Word XML Files Tag: 107967
Turning MS Documents into PowerPoint Presentations
How can I convert word document into PP presentation with images involve?
here are some criteria:
SLIDE TITLE: it must be BOLD with less than 10 word.
SLIDE BODY: any underline or italic in a specific paragraph after the slide
title.
IMAGE: can be found only in 1 slide,without any title/text description.
Your help would be greatly needed. thank you. Tag: Merge 2 Word XML Files Tag: 107964
Controlling The Order of User Namespace Declarations
Here is a question specific to WordprocessML resultant instance output whose
root element is w:wordDocument.
If I employeed multiple user schemas in my Microsoft Office Word 2003
document, how would the order of associated namespace declarations be
decided?
For instance, if two schemas www.mycompany.org/schema_a.xsd and
www.mycompany.org/schema_b.xsd were employeed, who would be deciding that
namespace ns5 is assigned first to www.mycompany.org/schema_a.xsd and then
ns6 to www.mycompany.org/schema_b.xsd rather than the reverse order?
Can doument author have any control in this regard? If yes, how to do that?
Any advice is appreciated.
Regards,
Spenser Tag: Merge 2 Word XML Files Tag: 107954
Macro Recording Process Acieved Macro Goal, Macro Itself Fails
I recorded a macro as I simultaneously (1) searched for all paragraphs of
outline level 8 and beginning with the text â??i.â?? followed by a tab character
and (2) replaced each instance of the above text with â??[a]â?? followed by a tab
character, and applied various formatting characteristics to each paragraph
found (including outline level 9). I was successful during the recording
process, but the resulting macro doesnâ??t work. Instead, I am informed that
â??0 replacements were madeâ??. (Of course, I had restored the search target to
the text.) The code, recorded automatically, is as follows:
Sub i__DemotedByJAW()
'
' i__DemotedByJAW Macro
' Macro recorded 11/23/2007 by James Watson
'
Selection.Find.ClearFormatting
With Selection.Find.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.OutlineLevel = wdOutlineLevel8
End With
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.ParagraphFormat
.LeftIndent = InchesToPoints(1.75)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.FirstLineIndent = InchesToPoints(0)
.OutlineLevel = wdOutlineLevel9
.CharacterUnitLeftIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = "i.^t"
.Replacement.Text = "[a]^t"
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Many thanks in advance for whomever assists me.
James Watson Tag: Merge 2 Word XML Files Tag: 107952
Ribbon Status
In a procedure I am writing I need to know if the Ribbon is displayed or
not.
I found ActiveWindow.ToggleRibbon which shows or hides the ribbon, but
couldn't find anything to tell me if it was showing or not.
Thanks.
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word. Tag: Merge 2 Word XML Files Tag: 107951
"Paste Special - Unformatted Text" Macro
Hi. Can somebody tell me how to create a macro to . . .
"Paste Special . . . UNFORMATTED Text"
(I've tried clicking onthe "Paste" toolbar icon during macro-creation, and
even though I DO try to record the "Unformatted Text" option, before closing
the recording . . . . when actually executing, the macro just performs a
STANDARD paste . . . i.e. NOT unformatted!)
Ugh.
Thanks for anybody's help. Tag: Merge 2 Word XML Files Tag: 107943
Passing Ms Word Data To Access
I have built a MS Word 97 form that sends data in the bookmarks to a
table in Access 97 when I click a command button on the Word form.
With the help of Robert Morley, Thanks Rob, I am able to get the data
into the Access table. The problem is that if a bookmark is a Date/
Time or Number and contains no data, I get the run time error 13 "Type
Mismatch" message. If the bookmarks contain data or is a text field,
the data fills the Access table fields just fine. I have placed data
in all of the bookmarks and everything works.
What code do I need to add to get this working
I'm also wondering if the same thing will happen with the text
bookmarks that have no data.
Many thanks to all of you guys and gals who so freely contribute your
knowledge to help people like me who know just enough to be dangerous.
Your help has gotten me out of many a jam.
Ron
Here's the code
Private Sub cmdSendToAccess_Click()
Dim strfldPerAssign As String '(Text field)
Dim strfldAccNum As Long '(Text field)
Dim strfldEventNum As String '(Text field-contains numbers and
letters)
Dim strfldEventDate As Date '(Date/Time field)
Dim strfldReqDate As Date '(Date/Time field)
Dim strfldCompleted As String '(Text field)
Dim strfldApp1 As String '(Text field)
Dim strfldApp1Shift As String '(Text field)
Dim strfldStartTime1 As Date '(Date/Time field)
Dim strfldEndTime1 As Date '(Date/Time field)
Dim strfldTotalTime1 As Date '(Date/Time field)
Set ThisDoc = ActiveDocument
strfldPerAssign = ThisDoc.FormFields("fldPerAssign").Result
strfldAccNum = ThisDoc.FormFields("fldAccNum").Result
strfldEventNum = ThisDoc.FormFields("fldEventNum").Result
strfldEventDate = ThisDoc.FormFields("fldEventDate").Result
strfldReqDate = ThisDoc.FormFields("fldReqDate").Result
strfldCompleted = ThisDoc.FormFields("fldCompleted").Result
strfldApp1 = ThisDoc.FormFields("fldApp1").Result
strfldApp1Shift = ThisDoc.FormFields("fldApp1Shift").Result
strfldStartTime1 = ThisDoc.FormFields("fldStartTime1").Result
strfldEndTime1 = ThisDoc.FormFields("fldEndTime1").Result
strfldTotalTime1 = ThisDoc.FormFields("fldTotalTime1").Result
Set wrkjet = CreateWorkspace("", "admin", "", dbUseJet)
Set MyDB = wrkjet.OpenDatabase("E:\App\WorkCompleted")
Set MyTbl = MyDB.OpenRecordset("JobAssignments")
With MyTbl
.AddNew
!PerAssign = strfldPerAssign
!accNum = CLng(strfldAccNum)
!EventNum = strfldEventNum
!EventDate = CDate(strfldEventDate)
!ReqDate = CDate(strfldReqDate)
!Completed = strfldCompleted
!App1 = strfldApp1
!App1Shift = strfldApp1Shift
!StartTime1 = CDate(strfldStartTime1)
!EndTime1 = CDate(strfldEndTime1)
!TotalTime1 = CDate(strfldTotalTime1)
.Update
End With
Set MyTbl = Nothing
Set MyDB = Nothing
Set wrkjet = Nothing
End Sub Tag: Merge 2 Word XML Files Tag: 107932
Link (OLE) with relative path
Hi
I have a framework of word documents which all have to link to a generic
word document which is always placed relative to the famework.
I would like to make the link in the documents with a relative path, instead
of the absolute path which is generated when using "paste special/link"
function.
I have tried to modufied the path in the "fields" but I cannot make it work
as expected.
This is what it looks like
{ LINK Word.Document.8 "\\\\Servdk03\\pharma\\LKP08_master\\Stamdata.doc"
"OLE_LINK19" \a \p }
This is what I'm looking for.
{LINK Word.Document.8 "\\..\\..\\..\\Stamdata.doc" "OLE_LINK19" \a \p}
However that doesn't seems to work.
--
BR
Henry Tag: Merge 2 Word XML Files Tag: 107911
Hi,
I am trying to merge 2 word XML files. I don't know if it is possible. If it
is, how would I do that?