Cant save workbook using Excel VBO

vmaneesh

Member
Hello,

I am unable to save a workbook that i created when i use the functionality, for ex Today() for the filename parameter.
This is how i created the excel first:
Create instance > Create Workbook > Activate Workbook > Save WorkBook as ( this has 3 parameters (handle, workbook name and file name)). So for the filename, when i give the value as Today()&"work.csv", it is throwing an error. Even though the expression is valid, i am still being shown the error "Internal:Could not execute code stage because exception thrown by code stage. The given key was not present in the dictionary"

Has anyone faced this before and are there any alternative options that i can try in order to save a csv file with date functionality in it?

Thanks.
 

VJR

Well-Known Member
Hello,

I am unable to save a workbook that i created when i use the functionality, for ex Today() for the filename parameter.
This is how i created the excel first:
Create instance > Create Workbook > Activate Workbook > Save WorkBook as ( this has 3 parameters (handle, workbook name and file name)). So for the filename, when i give the value as Today()&"work.csv", it is throwing an error. Even though the expression is valid, i am still being shown the error "Internal:Could not execute code stage because exception thrown by code stage. The given key was not present in the dictionary"

Has anyone faced this before and are there any alternative options that i can try in order to save a csv file with date functionality in it?

Thanks.
If Today returns a date with slashes in it then slashes are not allowed in any file name and hence you will be unable to save the file. You can format the date and then save it on the file name.
 

vmaneesh

Member
Thanks VJR. What i've done is i took today's date and converted it to text format and then tried to insert it as the file name.
for ex: this is what i gave as the file location value : "c:\users\user\document\[TodayDate]"&"-successful"

[TodayDate] is a a text data item which is stored in the format of "10Dec2018". When i run it, it is successfully executing the action but i end up getting "-successful" as the filename when i go check the documents folder. it is skipping the date part. Do you have any idea regarding this issue?
 

VJR

Well-Known Member
Thanks VJR. What i've done is i took today's date and converted it to text format and then tried to insert it as the file name.
for ex: this is what i gave as the file location value : "c:\users\user\document\[TodayDate]"&"-successful"

[TodayDate] is a a text data item which is stored in the format of "10Dec2018". When i run it, it is successfully executing the action but i end up getting "-successful" as the filename when i go check the documents folder. it is skipping the date part. Do you have any idea regarding this issue?

Supply the full path as follows:
"c:\users\user\document\" & [TodayDate] &"-successful.csv"
 

edwards142

New Member
Facing error and issues meanwhile saving the Excel workbook is very annoying in itself as this will put all your data under risk.

I have a simple solution to avoid data loss in this situation.

Move The Original Worksheets To A New Workbook:
  • Hit the shift + F11 button to add the filler Excel worksheet to your workbook
  • Now, group entire worksheets (accept the filler) and to do so, hit the first sheet and then keep Shift key pressed. Now tap to the last sheet.
  • Next, right-click the grouped sheets > and click Move or copy.
  • And in the To Book list > click (New Book) > click OK.
This will shift the active (grouped) worksheets to some new workbook.

So if your workbook has VBA macros then immediately copy old workbook’s module to new one.

you can grab more fixes like this, from this link:
source: Fix Excel Encountered Errors During Save
 
Top