Hi there,
I have a specific problem, but also wanted to guage everyone's thoughts on copying codes. For less knowledgeable people like myself, I sometimes find i difficult to write code from scratch, but now that I've been developing a database (with your help!) I'm starting to see how the code is working.
However, I recently copied some code to create an appointment in MS Outlook and adapted it to use existing data on my job form, as opposed to having the user enter everything from scratch.
AlthoughI adapted it, I keep getting a compile error for - Dim objOutlook As Outlook.Application
When I tested it in the database example I downloaded, my amendments worked. Now that I have copied the command click code into my database I'm getting compile errors. "User defined-type not defined"
So 2 questions:
1. Can anyone advise me on how to fix the compile error?
2. When copying code, do we just copy the code we see or are there other linked modules/macros etc that we should be copying as well?
Thanks,
Anthea
4 1513
What u are using is the outlook activex control. What this means is if u use it this way then u have to add a reference. For any controls u use, u must add them as a reference. From vba window, u go to Tools/References and check the appropriate one (in this case Microsoft Outlook Object Library)
Do remember with Microsoft, there controls are in different directories depending on what version office u use therefore these become broken if used with a different version.
Using this approach is known as early binding.
Dim outApp as Outlook.Application
set outApp = New Outlook.Application
Now I prefer to code this way so as to make use of the intellisense menu,
However when I release change, I change it to use Late Binding
Late binding is basically you create objects then create them, What this saves is you having to add the reference in your code so u never suffer from broken references.
eg
Dim outApp as Object
set outApp = CreateObject("Outlook.Application")
There is a slight overhead with late binding, but not one that is noticable nowadays.
Anthea
with regards to copying code, its all a learning process. You can copy a sample of code, and any additional stuff that u may need if specified.
If it doesnt work, see where the failings are and u may find u need to add something or change some declaration etc, it is not going to be the same thing.
In your case, its just knowing about adding references (early binding) and ive explained late binding as well, so hopefully now you understand.
The more u work with Access, the more comfortable and experienced you will become and you will soon learn what you need to do, just takes time Im afraid.
Good luck and Happy New Year :)
Hi there,
Thanks alot, that does make sense. One slight problem, I have NO idea where to put that first bit of code. I managed to find the references and select the Outlook option you mentioned.
But if I am to 'bind' globally (this is what I got from your post), I wasn't sure where to put the code:
Dim objOutlook As Outlook.Application
Set objOutlook = New Outlook.Application
Thanks
Anthea
Managed to get this working, so thanks for your help!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mindy Smith |
last post by:
Hello, when I installed Visual Basic .Net, for some
reason it didn't install the sample codes. Does anyone
know which CD the sample codes are on and how would I go
about installing it on my hard...
|
by: Jim Andersen |
last post by:
Hi,
I made a DTS-package and it works when I execute it manually, but when it is
run by the SQL Server Agent, it fails.
I have use the guide to create a maintenance plan. That doesn't work so...
|
by: Christian Blackburn |
last post by:
Hi Gang,
I don't know what to make of all of this, but I'm having nothing, but
trouble copying data to the clipboard which should be the easiest thing in
the world. The only systems I can get...
|
by: Al Bahr |
last post by:
Hi,
Anyone aware of sample codes or article on creating
Charts such as line, or Bar in VB.net?
Thanks
Al
|
by: DeanL |
last post by:
Hi all,
I'm having a few problems with a shared access 97 db. I have the
database split with the tables on the server and everything else in
"client" front ends with links to the tables, e.g....
|
by: Kelii |
last post by:
I've been trying to get this piece to work for a few hours, but have
given up. I hope someone out there can help, I think the issue is
relatively straightforward, but being a novice, I'm stumped....
|
by: JoeZ |
last post by:
Hi all,
I am looking for some sample codes in C#, in which, it can read a schema xsd
file and use it to validate an xml stream or file. Ideally the sample will
use XmlValidatingReader.
TIA,
...
|
by: smartx |
last post by:
New sample codes, direct x game programming at:
http://gptutors.com
With best wishes,
smartx.
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
| |