VBA AutoCAD Compile Error variable not defined










1














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.










share|improve this question



















  • 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






  • 1




    Thanks mate ` Dim strReturn As String` did the trick
    – stuboy
    Nov 12 at 13:04















1














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.










share|improve this question



















  • 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






  • 1




    Thanks mate ` Dim strReturn As String` did the trick
    – stuboy
    Nov 12 at 13:04













1












1








1







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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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". Define strReturn 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




    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




    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












2 Answers
2






active

oldest

votes


















1














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





share|improve this answer




















  • 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


















0














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






share|improve this answer




















    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
    );



    );













    draft saved

    draft discarded


















    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









    1














    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





    share|improve this answer




















    • 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















    1














    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





    share|improve this answer




















    • 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













    1












    1








    1






    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





    share|improve this answer












    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






    share|improve this answer












    share|improve this answer



    share|improve this answer










    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
















    • 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













    0














    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






    share|improve this answer

























      0














      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






      share|improve this answer























        0












        0








        0






        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






        share|improve this answer












        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







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 at 6:22









        stuboy

        61




        61



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3

            Museum of Modern and Contemporary Art of Trento and Rovereto