VBA AutoCAD Compile Error variable not defined
I have a .dvb file created in VBA, I am getting a compile error stating:
variable not defined
There are two modules of code one for the form and one for common dialog. The error I am getting is for common dialog code that has been swiped from somewhere else for handling Browse and adding drawings.
Common dialog code Module extract:
Public Function GetFiles( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
strReturn = FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True) 'code failing here "compile error variable not defined"
GetFiles = Split(strReturn, ",")
End Function
Form Code module extract:
Private Sub cmdAddDwg_Click()
Dim initFolder As String
Dim filter As String
Dim fileNames() As String
Dim i As Integer
initFolder = ThisDrawing.Path
filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*"
fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0)
If UBound(fileNames) > 0 Then
For i = 1 To UBound(fileNames)
lstDwgList.AddItem fileNames(0) & "" & fileNames(i)
Next
End If
End Sub
My VBA knowledge is limited at best.
Thanks in advance much appreciated.
vba autocad
add a comment |
I have a .dvb file created in VBA, I am getting a compile error stating:
variable not defined
There are two modules of code one for the form and one for common dialog. The error I am getting is for common dialog code that has been swiped from somewhere else for handling Browse and adding drawings.
Common dialog code Module extract:
Public Function GetFiles( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
strReturn = FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True) 'code failing here "compile error variable not defined"
GetFiles = Split(strReturn, ",")
End Function
Form Code module extract:
Private Sub cmdAddDwg_Click()
Dim initFolder As String
Dim filter As String
Dim fileNames() As String
Dim i As Integer
initFolder = ThisDrawing.Path
filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*"
fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0)
If UBound(fileNames) > 0 Then
For i = 1 To UBound(fileNames)
lstDwgList.AddItem fileNames(0) & "" & fileNames(i)
Next
End If
End Sub
My VBA knowledge is limited at best.
Thanks in advance much appreciated.
vba autocad
1
strReturn
is not defined, so you get a message "Variable not defined". DefinestrReturn
and you will get rid of the message.
– Vincent G
Nov 12 at 9:59
1
Thanks mate ` Dim strReturn As String` did the trick
– stuboy
Nov 12 at 13:04
add a comment |
I have a .dvb file created in VBA, I am getting a compile error stating:
variable not defined
There are two modules of code one for the form and one for common dialog. The error I am getting is for common dialog code that has been swiped from somewhere else for handling Browse and adding drawings.
Common dialog code Module extract:
Public Function GetFiles( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
strReturn = FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True) 'code failing here "compile error variable not defined"
GetFiles = Split(strReturn, ",")
End Function
Form Code module extract:
Private Sub cmdAddDwg_Click()
Dim initFolder As String
Dim filter As String
Dim fileNames() As String
Dim i As Integer
initFolder = ThisDrawing.Path
filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*"
fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0)
If UBound(fileNames) > 0 Then
For i = 1 To UBound(fileNames)
lstDwgList.AddItem fileNames(0) & "" & fileNames(i)
Next
End If
End Sub
My VBA knowledge is limited at best.
Thanks in advance much appreciated.
vba autocad
I have a .dvb file created in VBA, I am getting a compile error stating:
variable not defined
There are two modules of code one for the form and one for common dialog. The error I am getting is for common dialog code that has been swiped from somewhere else for handling Browse and adding drawings.
Common dialog code Module extract:
Public Function GetFiles( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
strReturn = FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True) 'code failing here "compile error variable not defined"
GetFiles = Split(strReturn, ",")
End Function
Form Code module extract:
Private Sub cmdAddDwg_Click()
Dim initFolder As String
Dim filter As String
Dim fileNames() As String
Dim i As Integer
initFolder = ThisDrawing.Path
filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*"
fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0)
If UBound(fileNames) > 0 Then
For i = 1 To UBound(fileNames)
lstDwgList.AddItem fileNames(0) & "" & fileNames(i)
Next
End If
End Sub
My VBA knowledge is limited at best.
Thanks in advance much appreciated.
vba autocad
vba autocad
edited Nov 12 at 11:24
Lee Mac
3,30731338
3,30731338
asked Nov 12 at 9:52
stuboy
61
61
1
strReturn
is not defined, so you get a message "Variable not defined". DefinestrReturn
and you will get rid of the message.
– Vincent G
Nov 12 at 9:59
1
Thanks mate ` Dim strReturn As String` did the trick
– stuboy
Nov 12 at 13:04
add a comment |
1
strReturn
is not defined, so you get a message "Variable not defined". DefinestrReturn
and you will get rid of the message.
– Vincent G
Nov 12 at 9:59
1
Thanks mate ` Dim strReturn As String` did the trick
– stuboy
Nov 12 at 13:04
1
1
strReturn
is not defined, so you get a message "Variable not defined". Define strReturn
and you will get rid of the message.– Vincent G
Nov 12 at 9:59
strReturn
is not defined, so you get a message "Variable not defined". Define strReturn
and you will get rid of the message.– Vincent G
Nov 12 at 9:59
1
1
Thanks mate ` Dim strReturn As String` did the trick
– stuboy
Nov 12 at 13:04
Thanks mate ` Dim strReturn As String` did the trick
– stuboy
Nov 12 at 13:04
add a comment |
2 Answers
2
active
oldest
votes
Either define your variable strReturn
as a string:
Public Function GetFiles ( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
Dim strReturn As String ' This line was missing
strReturn = FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True)
GetFiles = Split(strReturn, ",")
End Function
Or rewrite that section of the code to omit the strReturn
variable entirely:
Public Function GetFiles ( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
GetFiles = Split(FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True), ",")
End Function
Thanks Lee, You're every where..... is there a way of making a label lbldwglst show the amount of files in a listbox lstdwglist? with a prefix text string in the label "Number of drawings" ? I have tried listcount but keep getting compile errors, And ive only started learning VBA
– stuboy
Nov 14 at 4:43
Thanks Lee that is a much better way of writing the code. As stated above I have an 'add drawing' button name cmdAddDwg that uses common dialog to browse and select files and populate in a listbox lstDwgList is it possible to create a label lbldwglst at bottom of userform frmMultiScript that populates a count of the items in the listbox?
– stuboy
Nov 14 at 6:13
Private Sub cmdAddDwg_Click() Dim initFolder As String Dim filter As String Dim fileNames() As String Dim i As Integer initFolder = lastPath 'gets last known location filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*" fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0) If UBound(fileNames) > 0 Then For i = 1 To UBound(fileNames) lstDwgList.AddItem fileNames(0) & "" & fileNames(i) Next End If End Sub
@Lee Mac
– stuboy
Nov 14 at 6:15
@stuboy You're welcome - I'm glad that my answer helped. Your additional comments may be better answered as a separate question (this is a Q&A site, not a forum).
– Lee Mac
Nov 14 at 13:14
add a comment |
Private Sub cmdAddDwg_Click()
Dim initFolder As String
Dim filter As String
Dim fileNames() As String
Dim i As Integer
'initFolder = ThisDrawing.Path 'gets dwg folder path
initFolder = lastPath 'gets last known location
filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*"
fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0)
If UBound(fileNames) > 0 Then
For i = 1 To UBound(fileNames)
lstDwgList.AddItem fileNames(0) & "" & fileNames(i)
Next
End If
End Sub
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259578%2fvba-autocad-compile-error-variable-not-defined%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Either define your variable strReturn
as a string:
Public Function GetFiles ( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
Dim strReturn As String ' This line was missing
strReturn = FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True)
GetFiles = Split(strReturn, ",")
End Function
Or rewrite that section of the code to omit the strReturn
variable entirely:
Public Function GetFiles ( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
GetFiles = Split(FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True), ",")
End Function
Thanks Lee, You're every where..... is there a way of making a label lbldwglst show the amount of files in a listbox lstdwglist? with a prefix text string in the label "Number of drawings" ? I have tried listcount but keep getting compile errors, And ive only started learning VBA
– stuboy
Nov 14 at 4:43
Thanks Lee that is a much better way of writing the code. As stated above I have an 'add drawing' button name cmdAddDwg that uses common dialog to browse and select files and populate in a listbox lstDwgList is it possible to create a label lbldwglst at bottom of userform frmMultiScript that populates a count of the items in the listbox?
– stuboy
Nov 14 at 6:13
Private Sub cmdAddDwg_Click() Dim initFolder As String Dim filter As String Dim fileNames() As String Dim i As Integer initFolder = lastPath 'gets last known location filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*" fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0) If UBound(fileNames) > 0 Then For i = 1 To UBound(fileNames) lstDwgList.AddItem fileNames(0) & "" & fileNames(i) Next End If End Sub
@Lee Mac
– stuboy
Nov 14 at 6:15
@stuboy You're welcome - I'm glad that my answer helped. Your additional comments may be better answered as a separate question (this is a Q&A site, not a forum).
– Lee Mac
Nov 14 at 13:14
add a comment |
Either define your variable strReturn
as a string:
Public Function GetFiles ( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
Dim strReturn As String ' This line was missing
strReturn = FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True)
GetFiles = Split(strReturn, ",")
End Function
Or rewrite that section of the code to omit the strReturn
variable entirely:
Public Function GetFiles ( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
GetFiles = Split(FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True), ",")
End Function
Thanks Lee, You're every where..... is there a way of making a label lbldwglst show the amount of files in a listbox lstdwglist? with a prefix text string in the label "Number of drawings" ? I have tried listcount but keep getting compile errors, And ive only started learning VBA
– stuboy
Nov 14 at 4:43
Thanks Lee that is a much better way of writing the code. As stated above I have an 'add drawing' button name cmdAddDwg that uses common dialog to browse and select files and populate in a listbox lstDwgList is it possible to create a label lbldwglst at bottom of userform frmMultiScript that populates a count of the items in the listbox?
– stuboy
Nov 14 at 6:13
Private Sub cmdAddDwg_Click() Dim initFolder As String Dim filter As String Dim fileNames() As String Dim i As Integer initFolder = lastPath 'gets last known location filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*" fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0) If UBound(fileNames) > 0 Then For i = 1 To UBound(fileNames) lstDwgList.AddItem fileNames(0) & "" & fileNames(i) Next End If End Sub
@Lee Mac
– stuboy
Nov 14 at 6:15
@stuboy You're welcome - I'm glad that my answer helped. Your additional comments may be better answered as a separate question (this is a Q&A site, not a forum).
– Lee Mac
Nov 14 at 13:14
add a comment |
Either define your variable strReturn
as a string:
Public Function GetFiles ( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
Dim strReturn As String ' This line was missing
strReturn = FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True)
GetFiles = Split(strReturn, ",")
End Function
Or rewrite that section of the code to omit the strReturn
variable entirely:
Public Function GetFiles ( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
GetFiles = Split(FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True), ",")
End Function
Either define your variable strReturn
as a string:
Public Function GetFiles ( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
Dim strReturn As String ' This line was missing
strReturn = FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True)
GetFiles = Split(strReturn, ",")
End Function
Or rewrite that section of the code to omit the strReturn
variable entirely:
Public Function GetFiles ( _
ByVal sInitFolder As String, _
ByVal sTitle As String, _
ByVal sFilter As String, _
ByVal nFilterIndex As Integer) As String()
GetFiles = Split(FileBrowseOpen(sInitFolder, sTitle, sFilter, nFilterIndex, True), ",")
End Function
answered Nov 12 at 11:28
Lee Mac
3,30731338
3,30731338
Thanks Lee, You're every where..... is there a way of making a label lbldwglst show the amount of files in a listbox lstdwglist? with a prefix text string in the label "Number of drawings" ? I have tried listcount but keep getting compile errors, And ive only started learning VBA
– stuboy
Nov 14 at 4:43
Thanks Lee that is a much better way of writing the code. As stated above I have an 'add drawing' button name cmdAddDwg that uses common dialog to browse and select files and populate in a listbox lstDwgList is it possible to create a label lbldwglst at bottom of userform frmMultiScript that populates a count of the items in the listbox?
– stuboy
Nov 14 at 6:13
Private Sub cmdAddDwg_Click() Dim initFolder As String Dim filter As String Dim fileNames() As String Dim i As Integer initFolder = lastPath 'gets last known location filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*" fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0) If UBound(fileNames) > 0 Then For i = 1 To UBound(fileNames) lstDwgList.AddItem fileNames(0) & "" & fileNames(i) Next End If End Sub
@Lee Mac
– stuboy
Nov 14 at 6:15
@stuboy You're welcome - I'm glad that my answer helped. Your additional comments may be better answered as a separate question (this is a Q&A site, not a forum).
– Lee Mac
Nov 14 at 13:14
add a comment |
Thanks Lee, You're every where..... is there a way of making a label lbldwglst show the amount of files in a listbox lstdwglist? with a prefix text string in the label "Number of drawings" ? I have tried listcount but keep getting compile errors, And ive only started learning VBA
– stuboy
Nov 14 at 4:43
Thanks Lee that is a much better way of writing the code. As stated above I have an 'add drawing' button name cmdAddDwg that uses common dialog to browse and select files and populate in a listbox lstDwgList is it possible to create a label lbldwglst at bottom of userform frmMultiScript that populates a count of the items in the listbox?
– stuboy
Nov 14 at 6:13
Private Sub cmdAddDwg_Click() Dim initFolder As String Dim filter As String Dim fileNames() As String Dim i As Integer initFolder = lastPath 'gets last known location filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*" fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0) If UBound(fileNames) > 0 Then For i = 1 To UBound(fileNames) lstDwgList.AddItem fileNames(0) & "" & fileNames(i) Next End If End Sub
@Lee Mac
– stuboy
Nov 14 at 6:15
@stuboy You're welcome - I'm glad that my answer helped. Your additional comments may be better answered as a separate question (this is a Q&A site, not a forum).
– Lee Mac
Nov 14 at 13:14
Thanks Lee, You're every where..... is there a way of making a label lbldwglst show the amount of files in a listbox lstdwglist? with a prefix text string in the label "Number of drawings" ? I have tried listcount but keep getting compile errors, And ive only started learning VBA
– stuboy
Nov 14 at 4:43
Thanks Lee, You're every where..... is there a way of making a label lbldwglst show the amount of files in a listbox lstdwglist? with a prefix text string in the label "Number of drawings" ? I have tried listcount but keep getting compile errors, And ive only started learning VBA
– stuboy
Nov 14 at 4:43
Thanks Lee that is a much better way of writing the code. As stated above I have an 'add drawing' button name cmdAddDwg that uses common dialog to browse and select files and populate in a listbox lstDwgList is it possible to create a label lbldwglst at bottom of userform frmMultiScript that populates a count of the items in the listbox?
– stuboy
Nov 14 at 6:13
Thanks Lee that is a much better way of writing the code. As stated above I have an 'add drawing' button name cmdAddDwg that uses common dialog to browse and select files and populate in a listbox lstDwgList is it possible to create a label lbldwglst at bottom of userform frmMultiScript that populates a count of the items in the listbox?
– stuboy
Nov 14 at 6:13
Private Sub cmdAddDwg_Click() Dim initFolder As String Dim filter As String Dim fileNames() As String Dim i As Integer initFolder = lastPath 'gets last known location filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*" fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0) If UBound(fileNames) > 0 Then For i = 1 To UBound(fileNames) lstDwgList.AddItem fileNames(0) & "" & fileNames(i) Next End If End Sub
@Lee Mac– stuboy
Nov 14 at 6:15
Private Sub cmdAddDwg_Click() Dim initFolder As String Dim filter As String Dim fileNames() As String Dim i As Integer initFolder = lastPath 'gets last known location filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*" fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0) If UBound(fileNames) > 0 Then For i = 1 To UBound(fileNames) lstDwgList.AddItem fileNames(0) & "" & fileNames(i) Next End If End Sub
@Lee Mac– stuboy
Nov 14 at 6:15
@stuboy You're welcome - I'm glad that my answer helped. Your additional comments may be better answered as a separate question (this is a Q&A site, not a forum).
– Lee Mac
Nov 14 at 13:14
@stuboy You're welcome - I'm glad that my answer helped. Your additional comments may be better answered as a separate question (this is a Q&A site, not a forum).
– Lee Mac
Nov 14 at 13:14
add a comment |
Private Sub cmdAddDwg_Click()
Dim initFolder As String
Dim filter As String
Dim fileNames() As String
Dim i As Integer
'initFolder = ThisDrawing.Path 'gets dwg folder path
initFolder = lastPath 'gets last known location
filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*"
fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0)
If UBound(fileNames) > 0 Then
For i = 1 To UBound(fileNames)
lstDwgList.AddItem fileNames(0) & "" & fileNames(i)
Next
End If
End Sub
add a comment |
Private Sub cmdAddDwg_Click()
Dim initFolder As String
Dim filter As String
Dim fileNames() As String
Dim i As Integer
'initFolder = ThisDrawing.Path 'gets dwg folder path
initFolder = lastPath 'gets last known location
filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*"
fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0)
If UBound(fileNames) > 0 Then
For i = 1 To UBound(fileNames)
lstDwgList.AddItem fileNames(0) & "" & fileNames(i)
Next
End If
End Sub
add a comment |
Private Sub cmdAddDwg_Click()
Dim initFolder As String
Dim filter As String
Dim fileNames() As String
Dim i As Integer
'initFolder = ThisDrawing.Path 'gets dwg folder path
initFolder = lastPath 'gets last known location
filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*"
fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0)
If UBound(fileNames) > 0 Then
For i = 1 To UBound(fileNames)
lstDwgList.AddItem fileNames(0) & "" & fileNames(i)
Next
End If
End Sub
Private Sub cmdAddDwg_Click()
Dim initFolder As String
Dim filter As String
Dim fileNames() As String
Dim i As Integer
'initFolder = ThisDrawing.Path 'gets dwg folder path
initFolder = lastPath 'gets last known location
filter = "AutoCAD Drawing Files (*.dwg)|*.dwg|All Files (*.*)|*.*"
fileNames = GetFiles(initFolder, "Select Drawing Files", filter, 0)
If UBound(fileNames) > 0 Then
For i = 1 To UBound(fileNames)
lstDwgList.AddItem fileNames(0) & "" & fileNames(i)
Next
End If
End Sub
answered Nov 14 at 6:22
stuboy
61
61
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259578%2fvba-autocad-compile-error-variable-not-defined%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
strReturn
is not defined, so you get a message "Variable not defined". DefinestrReturn
and you will get rid of the message.– Vincent G
Nov 12 at 9:59
1
Thanks mate ` Dim strReturn As String` did the trick
– stuboy
Nov 12 at 13:04