Usage of Excel SaveAs Method

Hi all,

i want to use Excel.Workbook library as a saveAs but i couldn’t locate the where it should save just giving the name of the excel and saving in te documents.

My Code :

xlsWB.SaveAs(setFileName, XlFileFormat.xlWorkbookNormal)

NOT : xlsWB as an Excel.Workbook
setFileName as a String = “myExcel”

What a want is => setFileName = “C:\myExcel” when i do like this it gets me an error.
=> “exception has been thrown by the target of an invocation”

How can i set the location?

Thank you.

Hi @yigit.aybey
Have you try with full path and file name.
like this

->“C:\myExcel\myExcel”

1 Like

Hello @yigit.aybey
Try this
Environment.CurrentDirectory+"\Myexcelfile"

It creates files in your project location.

1 Like

Hello @yigit.aybey

As per my understanding if you just provide the file path it may get saved to the folder path.
Its better to give the full path of the file to save it to the required folder.

Thanks

1 Like

Hi @yigit.aybey

You need to provide an Extension to your file in the path.

For Example

“C:\Users\Admin\Downloads\Checkboxes\Samples\checkboxes.xlsx”

1 Like

Hi @Rahul_Unnikrishnan @raja.arslankhan @Gokul_Jayakumar

thx for responses.

What i did is putting the .xls after the naming the document, i’had never done that because i though this code => XlFileFormat.xlWorkbookNormal should had do that. so…

Thanks for help.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.