+ Reply to Thread
Results 1 to 5 of 5

vba to remove background cell colour when saved as pdf

Hybrid View

  1. #1
    Registered User
    Join Date
    09-04-2014
    Location
    adelaide,australia
    MS-Off Ver
    2011
    Posts
    3

    vba to remove background cell colour when saved as pdf

    Hi ppl,

    Wondering if anyone can help me solve a way my macro can remove the interior background colours from all cells so it is just a white background with black borders and font when i save my workbook as a PDF via a saveas command button i already have set up. Only trying to do this because of some printing issues my office has because the sheets are printed in b&w.

    The macro i use is

    VBA pdf save as cal form 1-1.gif

    I have found online some info along the lines of Range("Z1").Interior.ColorIndex = xlNone that i think will help but have no idea where to implement it into the macro. it may or may not, im not real sure. I need to be able to keep the borders around cells also

    Sheet looks like this

    Sample forum 1.png

    And want it to look like this when saved as a PDF

    Sample forum 2.png

    I'm new to vba side of things so any help would be appreciated

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: vba to remove background cell colour when saved as pdf

    Just before the line with:

    ActiveWorkbook.Export...................
    include a line like:

    Cells.Interior.ColorIndex = xlNone
    Just be sure to first save your file as .xls or .xlsm to avoid destroying the formats.
    Gary's Student

  3. #3
    Registered User
    Join Date
    09-04-2014
    Location
    adelaide,australia
    MS-Off Ver
    2011
    Posts
    3

    Re: vba to remove background cell colour when saved as pdf

    thanks jacobshavn but that did not seem to work, only brought up an error

    This is what i tried

    sample forum 3.gif

    is that correct?

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: vba to remove background cell colour when saved as pdf

    There is a special procedure for changing cells if you are Selecting multiple sheets. You must:

    1. Activate one of the Selected sheets
    2. Select the cells you are trying to mod

    Sub dural()
        ThisWorkbook.Sheets(Array("Sheet1", "Sheet2")).Select
        ThisWorkbook.Sheets("Sheet1").Activate
        Range("A1:AA73").Select
        Selection.Interior.ColorIndex = xlNone
    End Sub
    Last edited by Jakobshavn; 03-31-2015 at 07:41 PM.

  5. #5
    Registered User
    Join Date
    09-04-2014
    Location
    adelaide,australia
    MS-Off Ver
    2011
    Posts
    3

    Re: vba to remove background cell colour when saved as pdf

    i found that i forgot to put activesheet. in front of the range and it worked once i did that thanks. i only need this for the one sheet (calibration form) so the last post isn't necessary but thanks anyway. only trouble i have with it now is that it removes the colours cells not just from the pdf but also the worksheet too which i was hoping it wouldnt. i can live with it but if you know a way around this it would be good. also is it possible to remove the coloured cell that have been conditionally formated? im left with a few random greens and reds around the sheet

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. cell background colour
    By craig01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2015, 01:10 PM
  2. Replies: 2
    Last Post: 03-08-2014, 12:19 PM
  3. toggling background colour of a cell
    By roninn75 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-19-2012, 02:54 AM
  4. Cell Background Colour?
    By arfanvilla in forum Excel General
    Replies: 2
    Last Post: 05-12-2008, 05:34 AM
  5. [SOLVED] change a cell background colour to my own RGB colour requirements
    By Stephen Doughty in forum Excel General
    Replies: 4
    Last Post: 06-16-2006, 08:15 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1