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!
Printable View
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!
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
Hi,
It's "Set oword = Createobject..."
zaza
EDIT: Rats. Beaten to it. :cry:
Quote:
Originally Posted by zaza
Sorry about that... It happens all the time to everyone (Me too ;))
Cheers,
RyanJ :)
whenever i type "Set" it disapears. i am still getting an error. any suggestions?
What error are you getting?Quote:
Originally Posted by xxwhocaresxx
Cheers,
RyanJ
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.Quote:
Originally Posted by xxwhocaresxx
Are you using VB or VB.net?
Cheers,
RyanJ
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.Quote:
Originally Posted by xxwhocaresxx
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
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.
:confused:
zaza
Perhaps a help file search for creating objects in .Net or maybe 'automation' ?Quote:
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
Edit:
Possibly helpful links?
MSDN site
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.
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.