VBA & Macro Problems

How to Fix Excel VBA Macro Flickering but Not Creating PDF

Tauseeq MagsiTauseeq Magsi Nov 10, 2026 869 views

Question details

The user is executing an Excel VBA macro to export an invoice as a PDF, but the screen flickers and the PDF file is never created or saved.

How to Fix Excel VBA Macro Flickering but Not Creating PDF
Product
Excel
Device & OS
not provided
Scenario
Running an automated VBA macro to export specific spreadsheet data and save it as a PDF document into a local or OneDrive folder.
Observed behavior
The macro executes and causes the screen to flicker as if processing, but it finishes without saving the expected PDF file to the specified destination.
Before you start

Verify that the destination folder specified in your macro actually exists on your computer and that you have the correct write permissions to save files there.

Solution 1Recommended

Fix OneDrive Local Sync Settings

Ensure that your OneDrive folder is available locally on your computer, as VBA cannot save directly to cloud-only placeholders without throwing an error.

When using OneDrive, files and folders might be set to 'Files On-Demand' (online-only). If a VBA macro attempts to export a PDF to an online-only directory using a local file path, the script will silently fail to find the directory.

1
Locate destination folder

Open Windows File Explorer and navigate to the destination folder specified in your VBA macro (for example, the 'Invoices' folder on your Desktop or OneDrive).

2
Change sync status

Right-click the folder and select 'Always keep on this device'. Wait for the status icon to turn into a solid green circle, indicating the folder is available locally.

3
Verify file path format

Ensure your VBA code uses the local drive path (e.g., C:\Users\Name\OneDrive\...) rather than a OneDrive web URL (https://...).

Fix OneDrive Local Sync Settings
Check Folder Path Ending: Ensure your file path string inside the macro ends with a backslash (\) so the filename attaches correctly to the directory.

Automate PDF Exports Seamlessly with WPS Spreadsheet

WPS Office provides excellent support for VBA macros alongside a powerful built-in PDF converter, allowing you to run your invoice automation scripts reliably and efficiently.

  1. 1. Install WPS Office: Download and install the free WPS Office suite on your device.
  2. 2. Open your Macro Workbook: Launch WPS Spreadsheet and open your macro-enabled file (.xlsm).
  3. 3. Run VBA and Export: Press Alt + F11 to access the VBA Editor, verify your macro paths, and run the script to generate your PDFs flawlessly.
Fully compatible with Microsoft Excel VBA macros and .xlsm formatsBuilt-in, high-quality PDF export engine included for freeLightweight architecture runs macros smoothly without excessive interface flickeringFamiliar spreadsheet interface for a zero-learning-curve transition
microsoft office alternative - wps office

Frequently Asked Questions

How do I stop the screen from flickering when the VBA macro runs?

Screen flickering occurs because the application constantly redraws the screen as data changes. You can prevent this by opening the VBA editor and typing 'Application.ScreenUpdating = False' at the start of your macro, and 'Application.ScreenUpdating = True' at the end.

Why does the ExportAsFixedFormat method fail in VBA?

This method typically fails if the specified 'Filename' path does not exist, if you lack write permissions to the destination folder, or if the generated filename contains invalid characters (like / \ : * ? " < > |). Always ensure the target directory is fully created and spelled correctly.

Can OneDrive block my VBA macro from saving a file?

Yes. If the destination OneDrive folder is set to 'Files On-Demand' (online-only) or if the macro is attempting to use a web URL instead of a local file path, the VBA script will fail to locate the directory. Right-click the OneDrive folder in File Explorer and select 'Always keep on this device' to fix this.