Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Opening a Word doc and more

Hi all,
I want to put a button in col A that will open a Word doc thats title is
found in col B on the page number (of the doc) that is found in col C. Any
ideas?

Thanks all.

Chris.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Opening a Word doc and more

Maybe more than you wanted but this should handle
everything you need.

Dim wdAPP As Word.Application 'Bring in Word
extensibility
Dim wdDoc As Word.Document 'Identify a Word
Document
Dim sRNM As String 'Report Name

'Bring in Word Extensibility
Set wdAPP = CreateObject("Word.Application")
dAPP.Visible = True


'Open the Word Document
sRNM = "C:\path\documentname.doc"
Set wdAPP = CreateObject("Word.Application")
Set wdDoc = wdAPP.Documents.Open(sRNM)

WriteToWord("Text", linesbefore, linesafter, wdDOC, style)


'Save & Close the Word Document
With wdDoc
.Save
.Close
End With
wdAPP.Visible = True
wdAPP.Quit
Set wdAPP = Nothing
Set wdDoc = Nothing

Sub PageBreak()
wdAPP.Selection.EndKey Unit:=wdStory
With wdDoc.Range
.Characters.Last.InsertBreak Type:=wdPageBreak
End With
End Sub

Sub SetTabs()

wdAPP.Selection.ParagraphFormat.TabStops.Add _
Position:=InchesToPoints(0.25), _
Alignment:=wdAlignTabLeft,
Leader:=wdTabLeaderSpaces
wdAPP.Selection.ParagraphFormat.TabStops.Add _
Position:=InchesToPoints(1.25), _
Alignment:=wdAlignTabLeft,
Leader:=wdTabLeaderSpaces
wdAPP.Selection.ParagraphFormat.TabStops.Add _
Position:=InchesToPoints(4.5), _
Alignment:=wdAlignTabLeft,
Leader:=wdTabLeaderSpaces

End Sub

Public Function WriteToWord(sText As String, nBefore,
nAfter As Integer, xDoc, Optional sStyle As String)

Dim nCtr As Integer

With xDoc
If nBefore 0 Then
For nCtr = 1 To nBefore
.Content.InsertParagraphAfter
Next nCtr
End If

If sStyle < "" Then
wdAPP.Selection.EndKey Unit:=wdStory
wdAPP.Selection.HomeKey Unit:=wdLine,
Extend:=wdExtend
wdAPP.Selection.Style =
wdAPP.ActiveDocument.Styles(sStyle)
End If
.Content.InsertAfter sText

For nCtr = 1 To nAfter
.Content.InsertParagraphAfter
Next nCtr
End With
End Function


-----Original Message-----
Hi all,
I want to put a button in col A that will open a

Word doc thats title is
found in col B on the page number (of the doc) that is

found in col C. Any
ideas?

Thanks all.

Chris.



.

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
opening word document rk0909 Excel Discussion (Misc queries) 0 January 10th 07 02:42 PM
Hyperlink to rtf only opening in MS Word Ben J Excel Discussion (Misc queries) 0 September 30th 05 06:02 PM
Opening a csv file in word saybut Excel Discussion (Misc queries) 1 September 19th 05 06:15 PM
Opening spreadsheet & word very slow others ok Nokose Excel Discussion (Misc queries) 2 July 18th 05 03:24 PM


All times are GMT +1. The time now is 05:06 PM.

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"