find works for table but not textbox

D

Daniel

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
 
D

Daniel

I read the link you provided. Is range available in vb6? Somehow it does not
compile under vb6. I cannot declare range object.
 
H

Helmut Weber

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"
 
D

Daniel

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
 
H

Helmut Weber

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"
 
D

Daniel

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
 
D

Daniel

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
 
D

Doug Robbins

Do you have a reference set to the Word Object Model?

--
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
 
H

Helmut Weber

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"
 
D

Daniel

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
 
H

Helmut Weber

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"
 
D

Daniel

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
 
H

Helmut Weber

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top