ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro compile error (https://www.excelbanter.com/excel-programming/331302-macro-compile-error.html)

Jan Holmstrom

macro compile error
 
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?



John.Greenan

macro compile error
 
Try this:

Sub tester()
Dim lngVersion As Long

lngVersion = Application.Version

End Sub

--
That'll put the version number into lngVersion. You can then use that as a
variable in your code.

www.alignment-systems.com


"Jan Holmstrom" wrote:

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?



Jan Holmstrom

macro compile error
 
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 = "
.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:

Try this:

Sub tester()
Dim lngVersion As Long

lngVersion = Application.Version

End Sub

--
That'll put the version number into lngVersion. You can then use that as a
variable in your code.

www.alignment-systems.com


"Jan Holmstrom" wrote:

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?



Tushar Mehta

macro compile error
 
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

In article ,
says...
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 = "
.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:

Try this:

Sub tester()
Dim lngVersion As Long

lngVersion = Application.Version

End Sub

--
That'll put the version number into lngVersion. You can then use that as a
variable in your code.

www.alignment-systems.com


"Jan Holmstrom" wrote:

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?





All times are GMT +1. The time now is 03:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com