web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

"The automation variable has not been instantiated"

(0) ShareShare
ReportReport
Posted on by 169

When I am running the bellow code from Classic it works great.

When I am running the code from Role Tailored Client it send back the error
"The automation variable has not been instantiated".

Can anybody help me?

Name                     DataType Subtype Length
Shell32                   Automation 'Microsoft Shell Controls And Automation'.Shell 
ZipFolder                Automation 'Microsoft Shell Controls And Automation'.Folder 
IntegerValue          Integer  
i                                Integer  
TextFile                   File  
ZipFileName        Text  1024
SourceFileName Text  1024
ZipFile                    File  


CompressFileToZip(sourceFileAddress : Text[1024];destenationFileAddress : Text[1024])
ZipFileName := destenationFileAddress;
SourceFileName := sourceFileAddress;

//>>CREATING ZIP FILE
ZipFile.CREATE(destenationFileAddress); //here goes Your zip filename
ZipFile.TEXTMODE(FALSE); //binary mode
IntegerValue:=101010256;
//>>writing zip header
ZipFile.WRITE(IntegerValue);
IntegerValue:=0;
FOR i:=1 TO 9 DO
  ZipFile.WRITE(IntegerValue);
//<<writing zip header
ZipFile.CLOSE;
//<<zip file created c:\myzipfolder.zip

CREATE(Shell32,False, True); //creating shell automation
ZipFolder:=Shell32.NameSpace(destenationFileAddress); //ZIPFolder is now our folder in zip format which will be used
SourceFileName := sourceFileAddress;
//>>Copying file to our zip folder
ZipFolder.CopyHere(SourceFileName);
CLEAR(Shell32);

I have the same question (0)
  • Genie Cetas Profile Picture
    472 on at

    Try using Clear(Automation Variable) before this code

     "CREATE(Shell32,False, True); //creating shell automation"

  • Deniz Lapantov Profile Picture
    169 on at

    Thank you. I managed to do it with File Management (419).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,151

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,443 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,092 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans