Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default How to write in Word w/o Reference

Hello,
I need to write data and symbols in a Word document, without any Reference
to Microsoft Word 11.0 because another application is disturbed by such a
reference. So I tried the folowing macro, but the wdAlignParagraphCenter
and .Color = wdColorRed don't work until I reset the reference.
What can I do ?
Thanks for your help.

Gérard

Public Sub CALL_WORD()
Dim wrdApp As Object
Dim wrdDoc As Object
Dim MyTable4 As Object

Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True

Set wrdDoc = wrdApp.Documents.Open(FileName:="D:\Mes
documents\Pilotage\Fiche Pilotage 3 WPs V2.doc")

Set MyTable4 = wrdDoc.Tables(4)
MyTable4.Cell(Row:=4, Column:=11).Range.Text = Chr(236) 'Chr(236)
'Flèche ascendante
MyTable4.Cell(Row:=4, Column:=11).Range.Select
wrdDoc.Application.Selection.ParagraphFormat.Align ment =
wdAlignParagraphCenter 'Doesn't work!!!

With wrdDoc.Application.Selection.Font
.Name = "Wingdings"
.Size = 16
.Bold = True
.Color = wdColorRed ''Doesn't work!!!
End With

wrdDoc.Close SaveChanges:=True
wrdApp.Quit
Set wrdApp = Nothing
Set wrdDoc = Nothing

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default How to write in Word w/o Reference

Hi,

I've just answered your related post before reading this one.

On this 'wdAlignParagraphCenter' is only known when the reference is set.

wdAlignParagraphCenter will be part of an enumeration & therefore have a
numeric representation (just checked, it is 1). You would need to either
validate (or assume - as it probably is) that it was the same in all versions
& use the number, or, better set up your own enumeration within your code
(public type) with scope as required.

Regards,

Chris.

--
Chris Marlow
MCSD.NET, Microsoft Office XP Master


"Gérard Ducouret" wrote:

Hello,
I need to write data and symbols in a Word document, without any Reference
to Microsoft Word 11.0 because another application is disturbed by such a
reference. So I tried the folowing macro, but the wdAlignParagraphCenter
and .Color = wdColorRed don't work until I reset the reference.
What can I do ?
Thanks for your help.

Gérard

Public Sub CALL_WORD()
Dim wrdApp As Object
Dim wrdDoc As Object
Dim MyTable4 As Object

Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True

Set wrdDoc = wrdApp.Documents.Open(FileName:="D:\Mes
documents\Pilotage\Fiche Pilotage 3 WPs V2.doc")

Set MyTable4 = wrdDoc.Tables(4)
MyTable4.Cell(Row:=4, Column:=11).Range.Text = Chr(236) 'Chr(236)
'Flèche ascendante
MyTable4.Cell(Row:=4, Column:=11).Range.Select
wrdDoc.Application.Selection.ParagraphFormat.Align ment =
wdAlignParagraphCenter 'Doesn't work!!!

With wrdDoc.Application.Selection.Font
.Name = "Wingdings"
.Size = 16
.Bold = True
.Color = wdColorRed ''Doesn't work!!!
End With

wrdDoc.Close SaveChanges:=True
wrdApp.Quit
Set wrdApp = Nothing
Set wrdDoc = Nothing

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to write in Word w/o Reference

Using the hard coded number should be robust for any version that supports
that object/property/method

--
Regards,
Tom Ogilvy


"Chris Marlow" wrote:

Hi,

I've just answered your related post before reading this one.

On this 'wdAlignParagraphCenter' is only known when the reference is set.

wdAlignParagraphCenter will be part of an enumeration & therefore have a
numeric representation (just checked, it is 1). You would need to either
validate (or assume - as it probably is) that it was the same in all versions
& use the number, or, better set up your own enumeration within your code
(public type) with scope as required.

Regards,

Chris.

--
Chris Marlow
MCSD.NET, Microsoft Office XP Master


"Gérard Ducouret" wrote:

Hello,
I need to write data and symbols in a Word document, without any Reference
to Microsoft Word 11.0 because another application is disturbed by such a
reference. So I tried the folowing macro, but the wdAlignParagraphCenter
and .Color = wdColorRed don't work until I reset the reference.
What can I do ?
Thanks for your help.

Gérard

Public Sub CALL_WORD()
Dim wrdApp As Object
Dim wrdDoc As Object
Dim MyTable4 As Object

Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True

Set wrdDoc = wrdApp.Documents.Open(FileName:="D:\Mes
documents\Pilotage\Fiche Pilotage 3 WPs V2.doc")

Set MyTable4 = wrdDoc.Tables(4)
MyTable4.Cell(Row:=4, Column:=11).Range.Text = Chr(236) 'Chr(236)
'Flèche ascendante
MyTable4.Cell(Row:=4, Column:=11).Range.Select
wrdDoc.Application.Selection.ParagraphFormat.Align ment =
wdAlignParagraphCenter 'Doesn't work!!!

With wrdDoc.Application.Selection.Font
.Name = "Wingdings"
.Size = 16
.Bold = True
.Color = wdColorRed ''Doesn't work!!!
End With

wrdDoc.Close SaveChanges:=True
wrdApp.Quit
Set wrdApp = Nothing
Set wrdDoc = Nothing

End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to write in Word w/o Reference

these represent constants that are defined in the Word object library. When
you late bind, these constants are not defined and are just
undefined/uninitialized variables and result in a value of zero. The
solution is to use there defined value instead of the constant.

instead of
.Color = wdColorRed
you would do


? wdred
6

.color = 6


? wdAlignParagraphCenter
1

so

wrdDoc.Application.Selection.ParagraphFormat.Align ment = 1

as examples.

to get the values,

? wdAlignParagraphCenter
1

is from the immediate window of excel after creating a reference to word.

--
Regards,
Tom Ogilvy


"Gérard Ducouret" wrote:

Hello,
I need to write data and symbols in a Word document, without any Reference
to Microsoft Word 11.0 because another application is disturbed by such a
reference. So I tried the folowing macro, but the wdAlignParagraphCenter
and .Color = wdColorRed don't work until I reset the reference.
What can I do ?
Thanks for your help.

Gérard

Public Sub CALL_WORD()
Dim wrdApp As Object
Dim wrdDoc As Object
Dim MyTable4 As Object

Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True

Set wrdDoc = wrdApp.Documents.Open(FileName:="D:\Mes
documents\Pilotage\Fiche Pilotage 3 WPs V2.doc")

Set MyTable4 = wrdDoc.Tables(4)
MyTable4.Cell(Row:=4, Column:=11).Range.Text = Chr(236) 'Chr(236)
'Flèche ascendante
MyTable4.Cell(Row:=4, Column:=11).Range.Select
wrdDoc.Application.Selection.ParagraphFormat.Align ment =
wdAlignParagraphCenter 'Doesn't work!!!

With wrdDoc.Application.Selection.Font
.Name = "Wingdings"
.Size = 16
.Bold = True
.Color = wdColorRed ''Doesn't work!!!
End With

wrdDoc.Close SaveChanges:=True
wrdApp.Quit
Set wrdApp = Nothing
Set wrdDoc = Nothing

End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default How to write in Word w/o Reference

Thanks a lot Tom !

Gérard

"Tom Ogilvy" a écrit dans le message
de ...
these represent constants that are defined in the Word object library.

When
you late bind, these constants are not defined and are just
undefined/uninitialized variables and result in a value of zero. The
solution is to use there defined value instead of the constant.

instead of
.Color = wdColorRed
you would do


? wdred
6

.color = 6


? wdAlignParagraphCenter
1

so

wrdDoc.Application.Selection.ParagraphFormat.Align ment = 1

as examples.

to get the values,

? wdAlignParagraphCenter
1

is from the immediate window of excel after creating a reference to word.

--
Regards,
Tom Ogilvy


"Gérard Ducouret" wrote:

Hello,
I need to write data and symbols in a Word document, without any

Reference
to Microsoft Word 11.0 because another application is disturbed by such

a
reference. So I tried the folowing macro, but the

wdAlignParagraphCenter
and .Color = wdColorRed don't work until I reset the reference.
What can I do ?
Thanks for your help.

Gérard

Public Sub CALL_WORD()
Dim wrdApp As Object
Dim wrdDoc As Object
Dim MyTable4 As Object

Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True

Set wrdDoc = wrdApp.Documents.Open(FileName:="D:\Mes
documents\Pilotage\Fiche Pilotage 3 WPs V2.doc")

Set MyTable4 = wrdDoc.Tables(4)
MyTable4.Cell(Row:=4, Column:=11).Range.Text = Chr(236) 'Chr(236)
'Flèche ascendante
MyTable4.Cell(Row:=4, Column:=11).Range.Select
wrdDoc.Application.Selection.ParagraphFormat.Align ment =
wdAlignParagraphCenter 'Doesn't work!!!

With wrdDoc.Application.Selection.Font
.Name = "Wingdings"
.Size = 16
.Bold = True
.Color = wdColorRed ''Doesn't work!!!
End With

wrdDoc.Close SaveChanges:=True
wrdApp.Quit
Set wrdApp = Nothing
Set wrdDoc = Nothing

End Sub







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how i can write arabic numbers by microsoft excel word medo Excel Discussion (Misc queries) 1 February 10th 09 12:48 AM
How can I write a reference formula? ManhattanRebel Excel Discussion (Misc queries) 2 January 6th 09 02:50 PM
HOW PUT WORD-ART IN THE BACKGROUND AND WRITE OVER IT Militza Excel Worksheet Functions 1 August 25th 08 06:52 PM
How do I write macros with relative reference cells trilogylynch Excel Programming 3 July 25th 05 09:15 PM
Looking for documentation/reference to write Excel Macro [email protected] Excel Programming 2 March 11th 05 05:28 PM


All times are GMT +1. The time now is 05:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"