Hi,
I have code like this:
note that UnitName and PONum are string variables. This code is a piece of code from a button that will create a new Excel file with the name of 'UnitName-PONum'. So for example if UnitName is "Cutter" and PONum is "AAA505", then the Excel file created will be named Cutter-AAA505.xlsx
This is no problem with PONum such as "AAA505". But there are some cases that the PONum contains "/" , such as "Mail 17/06/13". If the PONum contains "/", it shows error saying Runtime Error 1004, MSOffice Excel Cannot access the file etc. etc. when the compiler goes to line [highlight #FCE94F]objBook.SaveAs (saveDir)[/highlight]
Is there any trick to overcome the problem with using "/"? Thank you
I have code like this:
Code:
Set objSheet = objExcel.Worksheets(1)
saveDir = "C:\Users\User\Desktop\" & UnitName & "-" & PONum & ".xlsx"
objBook.SaveAs (saveDir)
note that UnitName and PONum are string variables. This code is a piece of code from a button that will create a new Excel file with the name of 'UnitName-PONum'. So for example if UnitName is "Cutter" and PONum is "AAA505", then the Excel file created will be named Cutter-AAA505.xlsx
This is no problem with PONum such as "AAA505". But there are some cases that the PONum contains "/" , such as "Mail 17/06/13". If the PONum contains "/", it shows error saying Runtime Error 1004, MSOffice Excel Cannot access the file etc. etc. when the compiler goes to line [highlight #FCE94F]objBook.SaveAs (saveDir)[/highlight]
Is there any trick to overcome the problem with using "/"? Thank you