I have a complete windows form application created on VB.NET that uses excel and process and create some data. The code runs as expected when I run the project from the Visual Basic Studio application or the application file from bin\debug\
.
When I publish the project to create a windows application wizard, the application is only picking the application files and libraries. It is not selecting the excel file. Here is a code sample..
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles CommandButton.Click
Dim xlApp As Excel.Application
Dim xlWorkBook As Workbook
Dim xlWorkSheet As Worksheet
RegisterExcelToROT() 'Sub to register excel to ROT
xlApp = Marshal.GetActiveObject("Excel.Application")
xlWorkBook = xlApp.Workbooks.Open("Path to excel file")
xlWorkSheet = xlWorkBook.Worksheets("SheetName")
Some subs to manipulate the excel
End Sub
How to make an excel file to be part of the windows application publishing?
CodePudding user response:
In Visual Studio right click on the project and choose Add
-> Existing file
from the context menu and select the file you would like to get in the output folder. The file will be added to the list of files in your project. In the Solution Explorer
window select the just added file and open the Properties
window with its properties. Make sure that you have the following properties set up like shown on the screenshot: