Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
here is what I do so that I don't have version dependancies
'Module Level Code Public Function OpenDocument(FileName As String, WordApp As Object) As Object 'Open a word document template as a new document. On Error GoTo MyErr Set OpenDocument = WordApp.Documents.Add(Template:= _ FileName, NewTemplate _ :=False, DocumentType:=0) Exit Function MyErr: MsgBox "Unable to open Application Template. " & Err.Description Err.Clear Exit Function End Function 'Code to get is started Dim objWord As Object Dim objDoc As Object Set objWord = CreateObject("Word.Application") If Not objWord Is Nothing Then Set objDoc = OpenDocument(<somepathtotemplate, objWord) ...do some processing... objDoc.SaveAs FileName:= _ <somefilename, _ FileFormat:=0, LockComments:=False, Password:="", _ AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _ EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, _ SaveFormsData:=False, SaveAsAOCELetter:=False End If objWord.Quit Set objWord = Nothing "Tony White" wrote in message ... Ok here is a solution to open word in excel Sub OpenWord() 'In the references add Microsoft Word 10.0 or whatever your current version Dim wdApp As Word.Application Dim myFilename As String On Error Resume Next Set wdApp = GetObject(, "Word.Application") 'Sometimes this fails. If it fails do this If wdApp Is Nothing Then Set wdApp = GetObject("", "Word.Application") End If On Error GoTo 0 myFilename = "insert path here" myFilename = myFilename & strFilename With wdApp .Documents.Open Filename:=myFilename 'Make sure you set the visible property or the file will open but you won't see it .Visible = True End With Set wdApp = Nothing End Sub Notes: Depending on where the word document is located, you may want to put a status bar on the application so the user knows the file is opening. This will involve some extra coding and the subroutine above would call the status bar procedure a few times. I am not referring to the Excel status bar but a userform created to be a status bar. If you need help creating it, reply here and I'll give you the code. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
open word document in excel | Excel Discussion (Misc queries) | |||
what happens if I open an excel document in word? | Excel Discussion (Misc queries) | |||
open up a word document in excel | Excel Programming | |||
Open a word document in excel | Excel Programming | |||
open a word document in excel | Excel Programming |