Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 22484

Excel VBA macro can only save file to Sharepoint in debug mode

$
0
0

I have a piece of code that automates certain part of my work. I have installed it as a customised plugin so that running it is just one click in the Ribbon. However the code can only save file to Sharepoint if I'm running the macro manually in debug mode. If running it normally via the Ribbon it saves an empty file to Sharepoint which is not right. I have the below key codes if anyone can help me with it. It's quite a long one so I've omitted the part where the data format happens and the part where an automated email is being sent at the end.Thanks,

code to format data on current excel sheet

Application.ActiveSheet.UsedRange.CopySet NewBook = Workbooks.AddNewBook.Worksheets(1).Range("A1").PasteSpecial (xlPasteAll)NewBook.Worksheets(1).Columns("A:Z").Columns.AutoFitdateoutput = Format(Date, "dd.mm.yyyy")savefolder = "https://xxxxxxxx.sharepoint.com/personal/mycompanyusername/Documents/foldernamehere/"fullfilepath = savefolder & "DY Tracking " & dateoutput & ".xlsx"NewBook.SaveAs Filename:=fullfilepath, FileFormat:=xlOpenXMLWorkbook

code to initialize the automated email

I've tried to change my path around but nothing seems to work and the save file online is always empty. However, upon running the macro codes in debug mode it will be able to save successfully on Sharepoint.


Viewing all articles
Browse latest Browse all 22484

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>