+ Reply to Thread
Results 1 to 8 of 8

Command Buttons properties changing after export to PDF

  1. #1
    Forum Contributor
    Join Date
    01-08-2017
    Location
    Salt Lake City, Ut.
    MS-Off Ver
    2019 and 365
    Posts
    135

    Question Command Buttons properties changing after export to PDF

    I am using the following code to export visible excel sheets to a pdf. After it run all the activex command buttons have shifted locations and size. If I close the WB without saving then they return to their normal location and size. Does anyone have any ideas what may be causing this or how to fix it? I have tried stopping screen updates and saving the WB before the code runs but it still occurs. Help???

    "Sub ExportAsPdf()
    Dim FolderPath As String
    Dim FName As String
    Application.ScreenUpdating = False 'Stop Screens from updating while running code
    Call SaveWB

    Sheets("Baseline").Select
    FName = "Finance" & Range("M38").Value

    'Folder Path set to active users profile My Docments folder
    FolderPath = Environ$("UserProfile") & "\My Documents\"
    'MsgBox (FolderPath)
    'MsgBox (FName)
    'MkDir FolderPath

    'Export all visible sheets
    For Each ws In Sheets
    If ws.Visible = -1 Then
    ws.Select Not flg
    flg = True
    End If
    Next
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPath & "\" & FName, _
    openafterpublish:=False, ignoreprintareas:=False

    'MsgBox ("all PDFs have been sucessfully exported.")

    Application.ScreenUpdating = True
    End Sub
    "

  2. #2
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Command Buttons properties changing after export to PDF

    Hi,
    Good practise here is to use code tags.

    To avoid button size and location change try:
    - right click on a button, choose Format Control
    - on a tab Properties select "Don't move or size with cells"

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Command Buttons properties changing after export to PDF

    Hi,

    It is a common problem for activex controls on worksheets to change size and position- usually following a display or printer change, which I suspect exporting to PDF is related to. If at all possible, I would recommend replacing the activex buttons with either Form controls or shapes.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Forum Contributor
    Join Date
    01-08-2017
    Location
    Salt Lake City, Ut.
    MS-Off Ver
    2019 and 365
    Posts
    135

    Re: Command Buttons properties changing after export to PDF

    I found out that when I run this in Excel 2016 it works fine, but when I run it in excel 2010 then it fails with the original problem of relocating the command buttons. I have not tested it on any other versions yet.

  5. #5
    Forum Contributor
    Join Date
    01-08-2017
    Location
    Salt Lake City, Ut.
    MS-Off Ver
    2019 and 365
    Posts
    135

    Re: Command Buttons properties changing after export to PDF

    It also works on office 2013, so somewhere along the lines they fixed it. If you have to move to another version, I would suggest 2013, Office 2016 has too many issues and I get multiple errors when trying to run the same program on 2016. If you search the web, the opinions on 2016 are not at all favorable.

  6. #6
    Forum Contributor
    Join Date
    01-08-2017
    Location
    Salt Lake City, Ut.
    MS-Off Ver
    2019 and 365
    Posts
    135

    Re: Command Buttons properties changing after export to PDF

    Ok, so after several days of trying to resolve this problem and trying many suggestion that I found online, I decided to bite the bullet and upgrade to Office and Excel 2013. I preferred it over 2016, there are just too many thumbs down discussions around problems with 2016. In any case this solved my problem and the activex controls are fine now after printing or exporting to a pdf file.

  7. #7
    Forum Contributor
    Join Date
    01-08-2017
    Location
    Salt Lake City, Ut.
    MS-Off Ver
    2019 and 365
    Posts
    135

    Re: Command Buttons properties changing after export to PDF

    So, after purchasing office 2013 and recreating the ActiveX command buttons which did resolve the problem, I now have found that if I take that back and run it in 2010, it still works. So I spent a little bit of money to learn that I could have perhaps recreated the buttons on another system running 2013 and that would have resolved my problem.

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Command Buttons properties changing after export to PDF

    You can send me your new version of Excel .... just saying

+ 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. [SOLVED] Changing multiple command buttons caption on userform using VBA
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-02-2022, 05:17 PM
  2. Command Buttons changing Name/Losing applicable code
    By Coxy347 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-01-2019, 12:43 AM
  3. activeX controls command buttons are moving arround and changing forms and sizes
    By mandura in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-07-2015, 02:18 AM
  4. [SOLVED] A macro with several command buttons that export several sheets (seperately).
    By rimshot609 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-03-2014, 01:30 PM
  5. Useform Code - 12 Command Buttons dependant on other command buttons
    By darrenkaye in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-20-2013, 10:58 AM
  6. [SOLVED] Changing BackColor on Command Buttons?
    By RBee in forum Excel General
    Replies: 0
    Last Post: 08-15-2006, 01:25 PM
  7. [SOLVED] Command Buttons - can't click or open properties
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2005, 06:06 PM

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