MS Office Forum / Word / Programming / July 2005
find works for table but not textbox
|
|
Thread rating:  |
Daniel - 28 Jun 2005 20:59 GMT I use find with selection object and it works when I do in a document with tables. (replace does not work. So I use typetext to replace). But it does not work when I do with text boxes. I am using vb6 in visual studio 6 and word 2000.
Any help would be appreciated.
Daniel
Doug Robbins - 28 Jun 2005 22:12 GMT See the article "Using a macro to replace text where ever it appears in a document
including Headers, Footers, Textboxes, etc." at:
http://word.mvps.org/FAQs/Customization/ReplaceAnywhere.htm
 Signature Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis.
Doug Robbins - Word MVP
>I use find with selection object and it works when I do in a document with > tables. (replace does not work. So I use typetext to replace). But it does [quoted text clipped - 4 lines] > > Daniel Daniel - 28 Jun 2005 22:33 GMT I read the link you provided. Is range available in vb6? Somehow it does not compile under vb6. I cannot declare range object.
> See the article "Using a macro to replace text where ever it appears in a > document [quoted text clipped - 11 lines] > > > > Daniel Helmut Weber - 29 Jun 2005 15:26 GMT Hi Daniel,
once you got a word object (oWrd), you declare a range like that: Can't test it right now.
Dim WrdRange as oWrd.range ' not just range set WrdRange = owrd.activedocument.range
Greetings from Bavaria, Germany
Helmut Weber, MVP, WordVBA
Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de"
Daniel - 29 Jun 2005 15:58 GMT I am getting a compile error: User-defined type not defined
on
Dim wdRng As loWord.Range
in below codes.
As I mentioned in previous post, I am using vb 6 in visual studio 6. I am also using ms word 2000.
Any help would be appreciated.
Set loWord = CreateObject("Word.Application") Set doc1 = loWord.Documents.Open("c:\abc.dot") Set loSel = loWord.Selection Dim wdRng As loWord.Range Set wdRng = doc1.Range
> Hi Daniel, > [quoted text clipped - 10 lines] > Win XP, Office 2003 > "red.sys" & Chr$(64) & "t-online.de" Helmut Weber - 29 Jun 2005 16:23 GMT Hi Daniel,
maybe it's not my day, as it's terribly hot in bavaria, but it seems, you want to define a range, that would be an application's range, instead of a range of a document of the application.
HTH
Greetings from Bavaria, Germany
Helmut Weber, MVP, WordVBA
Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de"
Daniel - 29 Jun 2005 16:40 GMT It has been pretty hot here, too, in Chicago and not much rain.
I got code samples as shown below from the site Doug Robbins posted.
But when I define 'Dim myRange As Range', I am getting the same compile error.
Is this because I am using vb6 in visual studio 6?
Thanks Daniel
Sub FindAndReplaceFirstStoryOfEachType()
Dim myStoryRange As Range
For Each myStoryRange In ActiveDocument.StoryRanges With myStoryRange.Find .Text = "findme" .Replacement.Text = "" .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next myStoryRange
End Sub
> Hi Daniel, > [quoted text clipped - 11 lines] > Win XP, Office 2003 > "red.sys" & Chr$(64) & "t-online.de" Daniel - 29 Jun 2005 16:46 GMT Hi Helmut,
It has been pretty hot here in Chicago, too.
I got below sample codes from the site Doug Robbins posted. And when I try to define 'Dim myRange As Range', I am getting the same compile error I posted before. I am not sure whether it is because I am using vb6 in visual studio 6.
Thanks for your reply. Daniel
Sub FindAndReplaceFirstStoryOfEachType()
Dim myStoryRange As Range
For Each myStoryRange In ActiveDocument.StoryRanges With myStoryRange.Find .Text = "findme" .Replacement.Text = "" .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next myStoryRange
End Sub
> Hi Daniel, > [quoted text clipped - 11 lines] > Win XP, Office 2003 > "red.sys" & Chr$(64) & "t-online.de" Doug Robbins - 29 Jun 2005 20:58 GMT Do you have a reference set to the Word Object Model?
 Signature Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis.
Doug Robbins - Word MVP
> Hi Helmut, > [quoted text clipped - 39 lines] >> Win XP, Office 2003 >> "red.sys" & Chr$(64) & "t-online.de" Daniel - 30 Jun 2005 14:27 GMT How can I check whether I have a reference set to the Word Object Model?
Thanks Daniel
> Do you have a reference set to the Word Object Model? > [quoted text clipped - 41 lines] > >> Win XP, Office 2003 > >> "red.sys" & Chr$(64) & "t-online.de" Helmut Weber - 30 Jun 2005 15:34 GMT Hi Daniel
in the VBA-Editor: Tools, References
Greetings from Bavaria, Germany
Helmut Weber, MVP, WordVBA
Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de"
Daniel - 30 Jun 2005 15:56 GMT I am not using vba editor. I am using vb6 in visual studio 6. I am using vba codes to build ocx and called by vbscript.
If I used visual studio .net, will I have all the objects in word 2000.
Then, I am not sure whether I can build ocx and use it in vbscript.
Thanks Daniel
> Hi Daniel > [quoted text clipped - 7 lines] > Win XP, Office 2003 > "red.sys" & Chr$(64) & "t-online.de" Helmut Weber - 30 Jun 2005 16:17 GMT Hi Daniel,
if VB6 it is Project, References
Greetings from Bavaria, Germany
Helmut Weber, MVP, WordVBA
Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de"
Daniel - 05 Jul 2005 15:49 GMT After I added reference for word object, replace using range worked file.
When I build cab file for distribution, it includes word object file 9 (word 2000). Will this work for word 2002, too?
Thanks Daniel
> Hi Daniel, > [quoted text clipped - 6 lines] > Win XP, Office 2003 > "red.sys" & Chr$(64) & "t-online.de" Helmut Weber - 07 Jul 2005 13:27 GMT Hi Daniel,
I don't think so. In such cases "late binding" is often recommended.
There may be people in the VB-groups, who know better.
Greetings from Bavaria, Germany Helmut Weber, MVP "red.sys" & chr(64) & "t-online.de" Word 2002, Windows 2000
|
|
|