|
-
Jun 2nd, 2005, 01:08 PM
#1
Thread Starter
New Member
opening word doc
I am trying to open up a word document... and i keep getting an error,
here is my code
Dim oWord As Object
oWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Document.Open(Application.StartupPath & "\QuickStartManual.doc")
Thanks!
-
Jun 2nd, 2005, 01:25 PM
#2
Re: opening word doc
Tryb this:
VB Code:
Dim wdWord As Object
Dim wdDocument As Object
Set wdWord = CreateObject("Word.Application")
Set wdDocument = CreateObject("Word.Document")
Set wdDocument = wdWord.Documents.Open(wdWord.StartupPath & "\QuickStartManual.doc")
wdWord.Visible = True
Cheers,
RyanJ
-
Jun 2nd, 2005, 01:26 PM
#3
Re: opening word doc
Hi,
It's "Set oword = Createobject..."
zaza
EDIT: Rats. Beaten to it.
-
Jun 2nd, 2005, 01:34 PM
#4
Re: opening word doc
 Originally Posted by zaza
Hi,
It's "Set oword = Createobject..."
zaza
EDIT: Rats. Beaten to it. 
Sorry about that... It happens all the time to everyone (Me too )
Cheers,
RyanJ
-
Jun 2nd, 2005, 01:34 PM
#5
Thread Starter
New Member
Re: opening word doc
whenever i type "Set" it disapears. i am still getting an error. any suggestions?
-
Jun 2nd, 2005, 01:49 PM
#6
Re: opening word doc
 Originally Posted by xxwhocaresxx
whenever i type "Set" it disapears. i am still getting an error. any suggestions?
What error are you getting?
Cheers,
RyanJ
-
Jun 2nd, 2005, 01:53 PM
#7
Thread Starter
New Member
Re: opening word doc
it breaks my code and it says:
"An unhandled exception of type 'System.Runtime.InteropServices.COMException' occured in microsoft.visualbasic.dll"
i don't know if that helps any.
-
Jun 2nd, 2005, 02:11 PM
#8
Re: opening word doc
 Originally Posted by xxwhocaresxx
it breaks my code and it says:
"An unhandled exception of type 'System.Runtime.InteropServices.COMException' occured in microsoft.visualbasic.dll"
i don't know if that helps any.
I do not think that is to do with the VB code I gave you.
Are you using VB or VB.net?
Cheers,
RyanJ
-
Jun 2nd, 2005, 02:12 PM
#9
Thread Starter
New Member
Re: opening word doc
i don't think its the code either, but i am not sure what might be causing that error.
i am using vb.net and word 2003
-
Jun 2nd, 2005, 02:42 PM
#10
Re: opening word doc
 Originally Posted by xxwhocaresxx
i don't think its the code either, but i am not sure what might be causing that error.
i am using vb.net and word 2003
Ah, thought I had never seen that error in VB before.
You will havw to wait for the RobDog888 to have a look at this thread, I believe he knows VB.net and so should be able to help you 
Cheers,
RyanJ
-
Jun 2nd, 2005, 03:14 PM
#11
Re: opening word doc
Hi,
Where does it give you that error? I thought VBA was VB6...unless it is because you're importing a control or library or something you've created in .Net. I suspect that this is more to do with that than to do with your VBA code.
zaza
-
Jun 3rd, 2005, 02:52 AM
#12
Re: opening word doc
xxwhocaresxx i don't think its the code either, but i am not sure what might be causing that error.
i am using vb.net and word 2003
Perhaps a help file search for creating objects in .Net or maybe 'automation' ?
Edit:
Possibly helpful links?
MSDN site
Last edited by Ecniv; Jun 3rd, 2005 at 03:07 AM.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jun 3rd, 2005, 03:23 AM
#13
Re: opening word doc
Listen up ppl. Firstly, don't post VB.Net questions in a VBA forum because it does my head in.
Set is no longer needed in .Net and the compiler ignores it and deletes it as soon as you try to use it.
xxwhocaresxx: have you added a reference to the relevant Word object library? You'll need to do that in order to create an instance of the word application.
For my outlook program i just used a reference to Interop.Office.dll and then this code to create an outlook app object...
VB Code:
Private OutApp As Outlook.ApplicationClass
............
OutApp = New Outlook.ApplicationClass
You should be able to figure out how to do the equivalent Word version for yourself.
I don't live here any more.
-
Jun 3rd, 2005, 03:32 AM
#14
Re: opening word doc
To clarify the difference between the languages:
VBA = The village idiot. This guy is very slow witted and finds it hard to understand simple things.
VB6 = The family man, has 2.4 children and a labrador. Knows what he wants to do and does it his own way with little time for the new fangled methods. Reliable, gets the job done.
VB.Net = Extreme sports fanatic, control freak, slightly intense, irritable.
I don't live here any more.
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
|