macro compile error

G

Guest

When I send my exelfile to other user the macro doesn't work. When excuted it
displays "compile error".

I have made my macro in version 11 (2003) but I have several users of the
file and they can have version 9 or 10.

The users of my file are not able to set the macro references manually.

Can anyone help me with a macro which find and select the users version as
reference?
 
G

Guest

Try this:

Sub tester()
Dim lngVersion As Long

lngVersion = Application.Version

End Sub
 
G

Guest

Hi John,
Thanks for reply. I've tried to put your code in to my macro. But it can
still not identify the outlook version.
I am testing the macro with no reference to outlook at all, as my users may
never had set any references at all in the VBA editor.
This is my code:
ActiveWorkbook.Save
Dim IngVersion As Long
IngVersion = Application.Version
Dim olApp As Object
Set olApp = CreateObject("Outlook.Application")
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim CurrFile As String
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
ActiveWorkbook.Save
CurrFile = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
With olMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "ENERGIRAPPORTERING"
.Body = "HERMED FREMSENDES ENERGIRAPPORT FOR UNDERTEGNEDE"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
Set olMail = Nothing
Set olApp = Nothing
ActiveWorkbook.PrintOut
Application.DisplayAlerts = False
Application.Quit


"John.Greenan" skrev:
 
T

Tushar Mehta

Create the software on a machine on which you can set the reference to
Outlook 9 not Outlook 11.

Alternatively, on your machine, remove the reference to Outlook and
make your program work. Now, it should work on older machines -- as
long as you are not using constructs introduced in a later version of
the software.


--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top