Results 1 to 5 of 5

Thread: [RESOLVED] import a "*.bas" file into vb project

Threaded View

  1. #1

    Thread Starter
    Lively Member elmnas's Avatar
    Join Date
    Jul 2009
    Posts
    127

    Resolved [RESOLVED] import a "*.bas" file into vb project

    Hello VB Members,

    I posted in an old thread that was about "how to import a file to a vb project"

    I think I was not clear enough to make people understand.

    The thing is...

    I have made a code that loops through "*.xls" files.
    For each xls file the loop imports a "*.bas" file located here "C:\test\test.bas"

    The function runs "RUNME" inside the "*.bas"

    The actual problem

    Instead of an absolute path to the "*.bas" file I want to import the "*.bas" file into my vb project.

    The "*.bas" file should be imported to the vb project.

    I want to import the "*.bas" file to the vb project, regardless of computer.

    see code below:

    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    
    
            Dim myfile = "C:\test\test.bas"
    
            FolderBrowserDialog1.SelectedPath = My.Computer.FileSystem.SpecialDirectories.MyDocuments
            FolderBrowserDialog1.ShowNewFolderButton = True 'folderdialog button
            If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
                Dim mySelFile As String = FolderBrowserDialog1.SelectedPath
                Dim intcount As Integer = Nothing
                Tb_FilePath.Text = mySelFile
                If Not IO.Directory.GetFiles(mySelFile, "*.xls").Any() Then
                    MsgBox("there are no xls files here")
                    Application.Restart()
                End If
                For Each filename As String In IO.Directory.GetFiles(mySelFile, "*.xls") 'I define the type of all files the loop go through
    
    
                    excelApp.Workbooks.Open(filename)
                    excelApp.Visible = True
                    excelApp.VBE.ActiveVBProject.VBComponents.Import(myfile)
                    excelApp.Run("Run_one")
    
    
                    ' Create a new instance of Excel and make it visible.
                    Next
                '     MsgBox("Modified (" + intcount.ToString + ") Excel files")
            Else
    
                'if the user has not selected a folder, it is a warning
                MsgBox("No Folder selected", MsgBoxStyle.Exclamation, "No selected folders")
            End If
    Last edited by elmnas; Jun 15th, 2015 at 02:51 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width