Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Controling Excel using Word VBA | Excel Programming | |||
controling a .xls from another .xls | New Users to Excel | |||
Excel User Form using 2 Combo Box with 1st Combon controling the 2 | Excel Programming | |||
Controling navagation of a form | Excel Discussion (Misc queries) |