|
-
Oct 31st, 2002, 06:20 AM
#1
Thread Starter
Junior Member
Reg Getobject Funtion
Hi,
Would anyone please tell me why iam not able to view the word document which already exists.I only get the word application opened but not the actual document.
I gave the following code
dim x as object
set x=getobject("c:\l5.doc")
x.application.visible=true
Expecting your reply,
Thankyou,
shoba
-
Nov 1st, 2002, 04:13 AM
#2
You could always use the creatobject option for this:
VB Code:
Dim objWordApp As Object
Set objWordApp = CreateObject("Word.application")
objWordApp.Visible = True
objWordApp.documents.open "C:\file.doc"
-
Nov 1st, 2002, 04:17 AM
#3
Alternatively, if you're writing this in vb & not from a script try not to use late binding (createobject or getobject functions) and try to use one of these instead:
VB Code:
' At the top of a form
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
ShellExecute Me.hwnd, vbNullString, "C:\Path\file.doc", _
vbNullString, "C:\", SW_SHOWNORMAL
End Sub
or...
VB Code:
'Add a reference to the "Microsoft Word x.0 object library" from the
'the project menu>references option in vb.
Private Sub Form_Load()
Dim wrdApp As Word.Application
Set wrdApp = New Word.Application
wrdApp.Visible = True
wrdApp.Documents.Open "C:\path\file.doc"
End Sub
Last edited by alex_read; Nov 1st, 2002 at 04:22 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|