Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Controling Word from Excel

Hi

I have a macro where the infomation is being coppied from excel and
putting it in a word document. I can setup the font type and size
etc... no problems. What i would like to do is setup a header and a
footer in my excel macro and if i can set the pageup as well. Can
anyone point me in the right direction?

Thanks

Oggy


' Send commands to Word
With WordApp
.Documents.Add



With .Selection
.Font.name = "Times New Roman"
.Font.Size = 10
.Font.Bold = False
.Font.Italic = False
.ParagraphFormat.Alignment = 1
.TypeText Text:="QUOTATION"
.TypeParagraph

  #2   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 65
Default Controling Word from Excel

On Apr 30, 11:51 am, Oggy wrote:
Hi

I have a macro where the infomation is being coppied from excel and
putting it in a word document. I can setup the font type and size
etc... no problems. What i would like to do is setup a header and a
footer in my excel macro and if i can set the pageup as well. Can
anyone point me in the right direction?

Thanks

Oggy

' Send commands to Word
With WordApp
.Documents.Add

With .Selection
.Font.name = "Times New Roman"
.Font.Size = 10
.Font.Bold = False
.Font.Italic = False
.ParagraphFormat.Alignment = 1
.TypeText Text:="QUOTATION"
.TypeParagraph


Hi, Oggy. I'm assuming that you have an object set to WordApp, and a
reference set to Word (Tools References). Set an object to your
document -
Dim WordDoc As Word.Document
Set WordDoc = WordApp.Documents.Add
Then do not use the Selection object - use your document object.

With the document object, PageSetup will get you into all your
margins, and Content will get you the range to set font stuff for the
whole document. To type specfic text at specific paragraphs, use
something like
WordDoc.Paragraphs(1).Range.Text = "QUOTATION" & vbCrLf
You can use the Range object of specific paragraphs to set font
attrubutes for just those paragraphs.

The header and footer are a but more complicated. Each section has a
header and a footer (and it gets deeper than that, but you don't want
to go there if you don't have to!). So you have to first get into the
appropriate document section, then either the Header or Footer object
for that section. SInce you are creating a brand new document, unless
you are using a custom template, it should come fresh out of the box
with only one section. That makes things easy enough to set an object
to what you need.
Dim HdFt As HeaderFooter
Set HdFt = WordDoc.Sections(1).Headers(wdHeaderFooterFirstPag e)
' Do what you need here
Set HdFt = WordDoc.Sections(1).Footers(wdHeaderFooterFirstPag e)
' Do what you need here

Hope this helps some. You might want to post over to
microsoft.Word.VBA.general for more assistance.

Ed

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
Controling Excel using Word VBA Zoltar54 Excel Programming 8 February 21st 06 06:11 PM
controling a .xls from another .xls on-a-mission New Users to Excel 2 February 17th 06 06:28 AM
Excel User Form using 2 Combo Box with 1st Combon controling the 2 ca1358 Excel Programming 1 January 6th 06 12:27 AM
Controling navagation of a form Amanda Excel Discussion (Misc queries) 1 April 28th 05 07:51 PM


All times are GMT +1. The time now is 12:20 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"