Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Set Word Document Style

Hello Group,

I am trying to set a doc style from an excel macro to a word document.
I can set the style with "in-line" code, but cannot set the style (get
an "object" does not exist error)
from a sub procedure. I can move down in the word doc from a sub
procedure but it seems I cannot set the style for a line (like "Header
3", etc) Below is the sub procedure - what am I missing? I pass the
doc object and the application object.

Sub SelectBookMarkPlace(wApp As Word.Application, nCount As Integer)
With wApp.Selection
.MoveDown Unit:=wdParagraph, Count:=nCount, Extend:=wdMove
'.Style = thisDoc.Styles("Header 3")
End With
End Sub

thanks,

eholz1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Set Word Document Style

Untested.

It looks like ThisDoc isn't defined anywhere.

maybe ???

dim ThisDoc as object
set thisdoc = wApp.activedocument

And unless you have a reference set to MSWord, I think you'll have trouble with
those MSWord constants.

You may want to replace them with their values:

?wdParagraph
4
?wdMove
0



eholz1 wrote:

Hello Group,

I am trying to set a doc style from an excel macro to a word document.
I can set the style with "in-line" code, but cannot set the style (get
an "object" does not exist error)
from a sub procedure. I can move down in the word doc from a sub
procedure but it seems I cannot set the style for a line (like "Header
3", etc) Below is the sub procedure - what am I missing? I pass the
doc object and the application object.

Sub SelectBookMarkPlace(wApp As Word.Application, nCount As Integer)
With wApp.Selection
.MoveDown Unit:=wdParagraph, Count:=nCount, Extend:=wdMove
'.Style = thisDoc.Styles("Header 3")
End With
End Sub

thanks,

eholz1


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Set Word Document Style

Check the Styles Collection Object in Word VBA Help. The collection exists
under the Document object. Likewise the Selection object exists only in a
document. If you set an object to your document as Dave suggested, you
should get better results.

Sub SelectBookMarkPlace(wApp As Word.Application, nCount As Integer)

dim ThisDoc as object
set thisdoc = wApp.activedocument
With ThisDoc.Selection
.MoveDown Unit:=wdParagraph, Count:=nCount, Extend:=wdMove
.Style = ThisDoc.Styles("Header 3")
End With
End Sub



Untested, but probably closer to actual.

Ed

"Dave Peterson" wrote in message
...
Untested.

It looks like ThisDoc isn't defined anywhere.

maybe ???

dim ThisDoc as object
set thisdoc = wApp.activedocument

And unless you have a reference set to MSWord, I think you'll have trouble
with
those MSWord constants.

You may want to replace them with their values:

?wdParagraph
4
?wdMove
0



eholz1 wrote:

Hello Group,

I am trying to set a doc style from an excel macro to a word document.
I can set the style with "in-line" code, but cannot set the style (get
an "object" does not exist error)
from a sub procedure. I can move down in the word doc from a sub
procedure but it seems I cannot set the style for a line (like "Header
3", etc) Below is the sub procedure - what am I missing? I pass the
doc object and the application object.

Sub SelectBookMarkPlace(wApp As Word.Application, nCount As Integer)
With wApp.Selection
.MoveDown Unit:=wdParagraph, Count:=nCount, Extend:=wdMove
'.Style = thisDoc.Styles("Header 3")
End With
End Sub

thanks,

eholz1


--

Dave Peterson



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Set Word Document Style

Hello Ed,
I need new glasses! the style SHOULD BE "Heading 3" not Header 3!!!!

dumb one!!!

Thanks for the info


Ed wrote:
Check the Styles Collection Object in Word VBA Help. The collection exists
under the Document object. Likewise the Selection object exists only in a
document. If you set an object to your document as Dave suggested, you
should get better results.

Sub SelectBookMarkPlace(wApp As Word.Application, nCount As Integer)

dim ThisDoc as object
set thisdoc = wApp.activedocument
With ThisDoc.Selection
.MoveDown Unit:=wdParagraph, Count:=nCount, Extend:=wdMove
.Style = ThisDoc.Styles("Header 3")
End With
End Sub



Untested, but probably closer to actual.

Ed

"Dave Peterson" wrote in message
...
Untested.

It looks like ThisDoc isn't defined anywhere.

maybe ???

dim ThisDoc as object
set thisdoc = wApp.activedocument

And unless you have a reference set to MSWord, I think you'll have trouble
with
those MSWord constants.

You may want to replace them with their values:

?wdParagraph
4
?wdMove
0



eholz1 wrote:

Hello Group,

I am trying to set a doc style from an excel macro to a word document.
I can set the style with "in-line" code, but cannot set the style (get
an "object" does not exist error)
from a sub procedure. I can move down in the word doc from a sub
procedure but it seems I cannot set the style for a line (like "Header
3", etc) Below is the sub procedure - what am I missing? I pass the
doc object and the application object.

Sub SelectBookMarkPlace(wApp As Word.Application, nCount As Integer)
With wApp.Selection
.MoveDown Unit:=wdParagraph, Count:=nCount, Extend:=wdMove
'.Style = thisDoc.Styles("Header 3")
End With
End Sub

thanks,

eholz1


--

Dave Peterson


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
change excel document into word document mrsb Excel Discussion (Misc queries) 6 August 28th 07 12:58 PM
convert excel document to word document (not a picture) frendabrenda1 Excel Discussion (Misc queries) 2 October 6th 06 03:55 PM
How do I convert a word document into a Excel document gwiltz2 Excel Discussion (Misc queries) 1 October 22nd 05 07:04 PM
Can you transform an excel document into a word document? Tammy Excel Discussion (Misc queries) 1 May 19th 05 03:23 PM
How do I convert Word document into an Excel document? Jamie Excel Discussion (Misc queries) 3 April 7th 05 09:45 PM


All times are GMT +1. The time now is 03:13 AM.

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

About Us

"It's about Microsoft Excel"