473,472 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Automation of Office programs

I have created a program that allows for the automation of things in Word
documents, like changing the values of DocVariables and the links to Excel
Sheets. I did it using interoperoperatability, where I declare objects as
follows:

Dim oWordApp As New Microsoft.Office.Interop.Word.Application, after adding
a reference to Microsoft.Office.Core and a reference to Microsoft Word. I
could do this since I have the Primary Interop Assemblies installed on my
computer. Everything works fine.

But I then realized that if I install this on a client's computer, in
addition to needing the .Net framework installed, they will also have to
have the Primary Interop Assemblies installed. I would like to avoid
having to install the PIAs , so I went back and tried to access Word the old
fashion way. After adding a Reference to Word, I put the following code in
a subroutine on the form.

Dim WordApp as object
WordApp = CreateObject("Word.Application")
Dim docPath As String
Me.OpenFileDialog1.Filter = "Word files (*.doc)|*.doc"
If Me.OpenFileDialog1.ShowDialog() = DialogResult.OK Then
docPath = Me.OpenFileDialog1.FileName
End If
WordApp.Visible = True
'MsgBox("App Name = " & oWordApp.Name)
WordApp.Documents.Open(docPath)

This code works, and the Word document is opened. But in writing the code
above, I had no autocompletion, and if I make the WordApp a shared object at
the form level, other subs on the form say that the document is not open
even though it is.

How do you get the above type of code to work as it did in Visual Basic?

Nov 21 '05 #1
2 2423
I think your problem with autocompletion is due to the way in which you are
declaring the word objects.

Dim WordApp as object
WordApp = CreateObject("Word.Application")

Since you are declaring WordApp as an object VB has no reference to what
type of object it actually is and cannot provide the properties/methods etc
that you are looking for. I've done similar Word automation and I think if
you change your declaration to this:

Dim mobjWordApp As Word.Application

you should gain access to the autocompletion functionality. Hope this
helps.

Matt

"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:eS**************@tk2msftngp13.phx.gbl...
I have created a program that allows for the automation of things in Word
documents, like changing the values of DocVariables and the links to Excel
Sheets. I did it using interoperoperatability, where I declare objects as
follows:

Dim oWordApp As New Microsoft.Office.Interop.Word.Application, after adding a reference to Microsoft.Office.Core and a reference to Microsoft Word. I could do this since I have the Primary Interop Assemblies installed on my
computer. Everything works fine.

But I then realized that if I install this on a client's computer, in
addition to needing the .Net framework installed, they will also have to
have the Primary Interop Assemblies installed. I would like to avoid
having to install the PIAs , so I went back and tried to access Word the old fashion way. After adding a Reference to Word, I put the following code in a subroutine on the form.

Dim WordApp as object
WordApp = CreateObject("Word.Application")
Dim docPath As String
Me.OpenFileDialog1.Filter = "Word files (*.doc)|*.doc"
If Me.OpenFileDialog1.ShowDialog() = DialogResult.OK Then
docPath = Me.OpenFileDialog1.FileName
End If
WordApp.Visible = True
'MsgBox("App Name = " & oWordApp.Name)
WordApp.Documents.Open(docPath)

This code works, and the Word document is opened. But in writing the code
above, I had no autocompletion, and if I make the WordApp a shared object at the form level, other subs on the form say that the document is not open
even though it is.

How do you get the above type of code to work as it did in Visual Basic?

Nov 21 '05 #2
Even though I have added a reference to the Microsoft Word 11 Object
Library, when I type dim oWordApp as Word. there is no list of available
properties, etc. that pops up as there is when I type Dim oWordApp As New
Microsoft.Office.Interop.Word. In fact if I type dim oWordApp as
Word.Application, I get an error message to the effect that Word.Application
is not defined.

It is as if Visual Studio is forcing me to use the second method.
"Matthew Dill" <md***@ameritas.com> wrote in message
news:OO**************@TK2MSFTNGP10.phx.gbl...
I think your problem with autocompletion is due to the way in which you are declaring the word objects.

Dim WordApp as object
WordApp = CreateObject("Word.Application")

Since you are declaring WordApp as an object VB has no reference to what
type of object it actually is and cannot provide the properties/methods etc that you are looking for. I've done similar Word automation and I think if you change your declaration to this:

Dim mobjWordApp As Word.Application

you should gain access to the autocompletion functionality. Hope this
helps.

Matt

"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:eS**************@tk2msftngp13.phx.gbl...
I have created a program that allows for the automation of things in Word documents, like changing the values of DocVariables and the links to Excel Sheets. I did it using interoperoperatability, where I declare objects as follows:

Dim oWordApp As New Microsoft.Office.Interop.Word.Application, after adding
a reference to Microsoft.Office.Core and a reference to Microsoft Word.

I
could do this since I have the Primary Interop Assemblies installed on my computer. Everything works fine.

But I then realized that if I install this on a client's computer, in
addition to needing the .Net framework installed, they will also have to
have the Primary Interop Assemblies installed. I would like to avoid
having to install the PIAs , so I went back and tried to access Word the

old
fashion way. After adding a Reference to Word, I put the following code

in
a subroutine on the form.

Dim WordApp as object
WordApp = CreateObject("Word.Application")
Dim docPath As String
Me.OpenFileDialog1.Filter = "Word files (*.doc)|*.doc"
If Me.OpenFileDialog1.ShowDialog() = DialogResult.OK Then
docPath = Me.OpenFileDialog1.FileName
End If
WordApp.Visible = True
'MsgBox("App Name = " & oWordApp.Name)
WordApp.Documents.Open(docPath)

This code works, and the Word document is opened. But in writing the code above, I had no autocompletion, and if I make the WordApp a shared

object at
the form level, other subs on the form say that the document is not open
even though it is.

How do you get the above type of code to work as it did in Visual Basic?


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jabailo | last post by:
I came across this article while researching a VB6 430 error: INFO: Considerations for Server-Side Automation of Office http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757 ...
25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
12
by: Cheval | last post by:
Has anyone had any problems with inter-office automation between MS Word and MS Access in Office 2003? I have recently installed office 2003 in a new folder and have left the older office 2000...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
2
by: Alex Maghen | last post by:
Hi. I've seen several KBs on using .NET for MS Office Automation. But I have a particular question: I am developing a somewhat stand-alone .ASPX page which will need to do some relatively simple MS...
3
by: Mitchell Vincent | last post by:
Does anyone have some good examples of Excel automation with (VB).NET? I have some Excel spreadsheets that a customer needs parsed out but I've never tried to use Excel programatically before! ...
6
by: a.theil | last post by:
Please help! I need a simple excel automation, just 2 write some files into excel. I do: Dim oXL As Excel.Application Dim oWB As Excel.Workbook Dim oSheet As Excel.Worksheet Dim oRng As...
9
NeoPa
by: NeoPa | last post by:
In VBA (I expect VB would be similar) controlling another Office Application (Automation) can be done using the following steps : Ensure the Reference (VBA Window / Tools / References) has been...
0
by: Bullfrog | last post by:
My office application is really slow on Windows XP! First, some backgroud stuff. The MSAccess system that we use was developed while using Windows 2000, and Office 2000. At our new location,...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.