Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 + MsWord problem

Status
Not open for further replies.

greathope123

Programmer
Nov 1, 2011
84
GB
In App.Path & "\myDoc.doc", I have a Picture and a WordArt. Run following code, I got
"TextEffect.PresetTextEffect = -2"

Private Sub Command1_Click()
Dim wApp As New Word.Application, wDoc As Word.Document
wApp.Visible = True
Set wDoc = wApp.Documents.Open(App.Path & "\myDoc.doc")
Print "Count = " & wDoc.Shapes.Count
With wDoc.Shapes(2)
Print "Text = " & .TextEffect.Text
Print "TextEffect.PresetTextEffect = " & .TextEffect.PresetTextEffect
End With
End Sub

I thought there was some thing wrong. I then deleted the Picture and run following code, got
"TextEffect.PresetTextEffect = 3"
Can you tell me why!!

Private Sub Command2_Click()
Dim wApp As New Word.Application, wDoc As Word.Document
wApp.Visible = True
Set wDoc = wApp.Documents.Open(App.Path & "\myDoc.doc")
Print "Count = " & wDoc.Shapes.Count
With wDoc.Shapes(1)
Print "Text = " & .TextEffect.Text
Print "TextEffect.PresetTextEffect = " & .TextEffect.PresetTextEffect
End With
End Sub
 


hi,

Change this
Code:
With wDoc.Shapes(2)
Print "Text = " & .TextEffect.Text
Print "TextEffect.PresetTextEffect = " & .TextEffect.PresetTextEffect
End With
to this...

Code:
dim shp as shape
for each shp in wDoc.shapes
with shp
Print "Text = " & .TextEffect.Text
Print "TextEffect.PresetTextEffect = " & .TextEffect.PresetTextEffect
End With
next


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks a lot for your response.

your code cannot work in my case because there is a Picture in the collection wDoc.shapes and Picture got no .TextEffect
 



just add
Code:
on error resume next


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi,

After add "on error resume next", got
Compile error:
Method or data member not found
highlighted at ".TextEffect
 


Code:
        With shp
            If .Type = msoTextBox Then
                Debug.Print "Text = " & .TextEffect.Text
                Debug.Print "TextEffect.PresetTextEffect = " & .TextEffect.PresetTextEffect
            End If
        End With

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 


oops
Code:
If .Type = [b]msoTextEffect[/b] Then

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thank you.

This time got Compile error:
Meshod or data member not found
highlineded at ".Type"

After commented "Dim shp As Shape", code works with output
Text = the text in the WordArt
TextEffect.PresetTextEffect = -2
 


plezse post all your code as you are currently running.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi,

Firstly, I should say sorry to you for my misleading!

I have just found the problem is not related to the Picture in the .doc file, it is the WordArt itself. When tried menu Format -> WordArt Styles, I was suprised that the WordArt in the .doc file got no WordArt Style! I just don't know how this WordArt can be inserted into the .doc without Style. The .doc is from other person.

Don't know if I can upload the .doc or not.....or, if you don't mind, I will email to you.
 


I do not believe that a WordArt object can have a style applied, as it is a document shape and not document text.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 



Are you certain that your WordArt is a Shape and not an InlineShape?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Sorry, I didn't make clear. I wasn't talking about the code, I meant in the document menu.

In Word 2007, click the WordArt object, in the menu we can see WordArt Tools -> Format -> WordArt Styles -> a few icons for various styles. One of the icons will be highlighted: that is what I said "WordArt Style".

In my last post, I said "WordArt in the .doc file got no WordArt Style", that meant there was no highlighted WordArt Style icon for that WordArt object.
 


This is a VB Code forum, and we have been discussing your VB Code.

If you need to discuss MS Office features, then please post in forum68.

If you are interested in discovering properties of your WordArt Object, then try using the Watch Window in the VB Editor.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top