Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8986561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:34:47+00:00 2026-06-15T21:34:47+00:00

I have 1 routine that is structured like this: C# console C opens xl

  • 0

I have 1 routine that is structured like this:

  1. C# console C opens xl workbook A
  2. C then runs A’s macro M which saves the target worksheet as a PDF using VBA
  3. C then uses PDFsharp to encrypt the PDF file.
  4. C then emails this file.

Currently this procedure is for one report so no problem if the architecture isn’t textbook.

I imagine in the future there may be many target worksheets in many different workbooks all going to lots of different recipients. If this is the case then Step 2 will need to go as I will not want to have to copy this VBA code into every target workbook! The only alternative I can imagine as my experience is limited is the following:

  1. Take the current VBA code out of Excel and move it into C using a reference to Excel.Interops

Assuming that the target worksheets are the finished article i.e. no further manipulation is required before going to PDF is the above the correct approach for moving this step out of VBA and into the console, or should I create the PDF using a different library?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:34:48+00:00Added an answer on June 15, 2026 at 9:34 pm

    The least-effort option is moving the code from the worksheet into a VBA add-in by deleting all the sheets/data out and then use ‘save as’ to turn the workbook into an add-in which you can then load into excel and will be available all the time. Depending on how you’ve written it some changes may be required but they won’t be as big as a port to c#.

    That said, having the code all in one place will make the whole process easier to look after in the future. Plus you’ve already got C# code automating excel to fire the VBA so it may be better to do it now if you have time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this routine that works well, but it messes up as it counts
I have a routine that examines thousands of records looking for discrepancies. This can
I have a jquery routine that calls an MVC action which will do a
I have a bunch of code in a routine that looks a bit like
I recently ran across a routine that looks something like this: procedure TMyForm.DoSomething(list: TList<TMyObject>;
I have a large (~100GB) text file structured like this: A,foobar A,barfoo A,foobar B,barfoo
I have this javascript routine for ajax call, which works for the most part.
I have a routine that dynamically changes a select list's selected option when the
I'm developing an MVC application and I have a routine that gets the currently
Good Day, I have a simple working routine in Perl that swaps two words:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.