+ Reply to Thread
Results 1 to 19 of 19

Accessing data from excel to use within a Publisher macro

  1. #1
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Accessing data from excel to use within a Publisher macro

    I don’t know if this is even possible or not but here is my situation.

    I have an excel file that is doing the heavy lifting of some mathematics. I also have a very nice to look at publisher document that is linked to those cells.

    What I would like to do is be able to run a macro in Publisher that will save this file to a specific location and with a name that are both specified in ZZ1 and ZZ2 of the excel file. As it stands now I have to do this manually and while that’s not such a big deal I want to replicate this for about 30 other sets of data. This would require me to save each one manually and thusly does start to become a bit of a pain.

    It would be cool to be able to open publisher file one that links to worksheet1 in the excel file…. Then saves in the correct location when I click on the macro… open publisher file 2 that links to worksheet2 and do on……

    Is this doable?

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Accessing data from excel to use within a Publisher macro

    I do not understand what you are wanting to do

    Which file do you want to save? - is it the "heavy" workbook? one linked worksheet? A publisher file?
    What is in ZZ1 (location?) and ZZ2 (file name?) - are there different values in each sheet?

    What exactly are you wanting the macro to do? Please list every step very simply

    1.Open Publisher File1
    2. ??? what happens next
    3. ???
    4. Save Publisher file1 ? Save linked worksheet as new workbook?
    5. Close Publisher file1 ?
    6. Open Publisher File2
    7. ??? what happens next
    8. ???
    9. Save Publisher file2 ? Save linked worksheet as new workbook?
    10. Close Publisher file1 ?

    How is each publisher file and worksheet "linked"?

    Are all the Publisher files in the same folder? Should all files in folder be opened?

    thanks
    Last edited by kev_; 01-04-2018 at 09:13 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Re: Accessing data from excel to use within a Publisher macro

    Thanks very much for reaching out to me kev on this. I appreciate it very much and will try to be more detailed.
    Here is how it works:
    I open the excel sheet (let’s say it’s NOT in the same folder) and update a few numbers. Those numbers are used to update a chart, and a table of info.
    I then open the publisher file and it will prompt me to update links… which are all pasted as “special” originally from the excel file. I say yes… and after a few moments the publisher files updates and looks great. At this point is where I have to save the file to a specific location using that months date.
    I currently know how to create a pdf file and save it with the name and destination I choose in excel. The cell location ZZ1 is the name of the file and ZZ2 is the name of the location on my hard drive to save it. I used to make the “publisher” files IN excel but it has become very difficult to make them look as good as they are needed so I had to move over to publisher. What I would like is to be able to do is to open that publisher file... say yes to updating and then click the macro run in publisher that will get the file name and file location and then save the publisher file as a pdf.
    Does this all make sense?

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Accessing data from excel to use within a Publisher macro

    ----------------------------------------------------------------------------------------------------------
    My interpretation:
    I have listed every individual step:
    - each step must be in the correct sequence
    - each step needs VBA code
    - if anything is missing then insert an additional step for me
    - if any step not correct, then amend it
    - also please answer all the questions

    Is this what you want?
    - open the Excel workbook - 1 is this always the same workbook?
    - update numbers for month
    - charts & table are auto-updated
    - save amended Excel workbook
    - open standard Publisher document - 2 is this always same document
    - update links -3 are these linked charts\tables?
    - save latest Publisher document - 4 what is the name string? - is it a default file name PLUS month's date?
    - create pdf file - 5 is this based on latest Publisher document?
    - save pdf with name specified in cell ZZ1 - 6 in which sheet are ZZ1 and ZZ2?
    - save pdf to folder specified in cell ZZ2
    ----------------------------------------------------------------------------------------------------------


    Please correct:

    Steps
    - open the Excel workbook
    - update numbers for month
    - charts & table are auto-updated
    - save amended workbook
    - open standard Publisher document
    - update links
    - save latest Publisher document
    - create pdf file
    - save pdf with name specified in cell ZZ1
    - save pdf to folder specified in cell ZZ2

    Please answer:
    Questions
    1 is this always the same workbook?
    2 is this always same (Publisher) document?
    3 are these linked charts\tables?
    4 what is the (Publisher document) name string? - is it a default file name PLUS month's date?
    5 is this (pdf) based on latest (Publisher) document?
    6 in which sheet are (cells) ZZ1 and ZZ2?
    Last edited by kev_; 01-04-2018 at 11:34 AM.

  5. #5
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Re: Accessing data from excel to use within a Publisher macro

    I have attached some example files. ZZ1 and ZZ2 are replaced with V2 and V3.

    The actual excel file has 30 workbooks with each one having different data and a different V2 and V3.

    HOWEVER the macro will be RUN from 1 of the 30 publisher files. Does that make sense? The excel file is the holder of all of the publishers data.

    I want to be able to have the excel file in a different directory just in case.

    BAH (the uploader wont let me give you the publisher file). But i am coping both a chart and cells from excel and pasting them as SPECIAL LINKED in publisher. So when i open publisher it first asks me if i want to update.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Accessing data from excel to use within a Publisher macro

    for each of the 30 publisher files there is a separate sheet in the workbook
    Each sheet contains 2 cells with location and file name
    Each worksheet is updated each month

    Are you using the same 30 publisher files every month updating links then creating 30 new publisher files and then 30 new PDF files?
    Do the 30 sheet names EXACTLY match the 30 publisher file names?

  7. #7
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Re: Accessing data from excel to use within a Publisher macro

    for each of the 30 publisher files there is a separate sheet in the workbook
    YES

    Each sheet contains 2 cells with location and file name
    YES

    Each worksheet is updated each month
    YES- but i can update them multiple times so there will never be a time with i would run a BULK report (updating and saving all 30 files at once)

    Are you using the same 30 publisher files every month updating links then creating 30 new publisher files and then 30 new PDF files?
    YES

    Do the 30 sheet names EXACTLY match the 30 publisher file names?
    The CAN if that helps. Sure.

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Accessing data from excel to use within a Publisher macro

    Ok
    - I now understand what you are trying to achieve
    - I will try out some VBA and aim to update the thread tomorrow afternoon

    ----------------

    Is the Excel file updated several times per month? (Eg piecemeal by worksheet?)
    Do you then update relevant Publisher files...
    - immediately?
    - at some random time?
    - to a given schedule?
    (It does not matter until after we get the basics working,) but I am wondering whether VBA could helpfully track amendments to the 30 worksheets versus updates to Publisher documents so that (at any given moment) you could see whether any Publisher documents require updating.
    (I am guessing that you keep some manual check running at the moment)

  9. #9
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Re: Accessing data from excel to use within a Publisher macro

    Is the Excel file updated several times per month? (Eg piecemeal by worksheet?)
    YES

    Do you then update relevant Publisher files...
    - immediately?
    SOMETIMES

    - at some random time?
    SOMETIMES

    - to a given schedule?
    NOT REALLY

    (It does not matter until after we get the basics working,) but I am wondering whether VBA could helpfully track amendments to the 30 worksheets versus updates to Publisher documents so that (at any given moment) you could see whether any Publisher documents require updating.
    (I am guessing that you keep some manual check running at the moment)
    Last edited by AliGW; 01-05-2018 at 09:44 AM.

  10. #10
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Re: Accessing data from excel to use within a Publisher macro

    I dont know if this will help or not but i found some code that will open a publisher file from excel and save it as a PDF. i can NOT however figure out HOW to force the publisher file to UPDATE LINKS...

    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Accessing data from excel to use within a Publisher macro

    deleted by kev
    Last edited by kev_; 01-07-2018 at 09:25 AM.

  12. #12
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Accessing data from excel to use within a Publisher macro

    I believe I have cracked it

    The problem with updating links reverses if opening Publisher files from Excel
    - the links do not update without being forced! (I find that ironic!)
    - the benefit of this is that we don't get any messages interrupting the VBA

    The method is
    - in each worksheet create the name strings for that sheet's masterfile and new pdf and publisher files
    - create one macro to do the updating
    - add a Form Control button(not Active-X) to each sheet to run the update
    - ensure each button has the same name (code required multiple times otherwise - once per button name)

    Picture from sample worksheet:

    NameStrings.jpg

    Both bits of VBA are placed in a general module
    Please Login or Register  to view this content.
    Button code
    Please Login or Register  to view this content.
    Attached is the Excel masterfile that I used for testing
    - it will not work for you until you amend the various formula but I think it will help you understand everything
    - V4, V6 and V7 in each worksheet contain formulas to provide the name strings required
    - those values are passed from the Button macro and used in the Update macro
    - you need to amend those formulas to provide the strings that works with your file structure
    - any file with the same name is overwritten
    - do you need a warning to give you the option to back out if the file already exists?

    My folder structure was simple
    - I put everything in the same folder
    - I guess you have 30 different folders (which is not an issue as this is set in each workskeet separately)
    - I am using the same name for publisher and pdf files (only extension differs)

    This is what I ended up with for NameA and NameB
    -ignore the first item (earlier testing detritus):


    CreatedPublisherFiles.jpg


    If you need further help send me a PM to wake me up!
    Attached Files Attached Files
    Last edited by kev_; 01-07-2018 at 10:29 AM. Reason: minor amendment to code

  13. #13
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Accessing data from excel to use within a Publisher macro

    WARNING
    The 30 publisher documents always contains inks to the Excel file
    (each is a copy of the master publisher master containing links)
    - it would be safer to break the link after the images have been updated
    - replying YES to the update links message would result in a previous month file being updated to the latest Excel values which is NOT correct treatment
    - I will look into this further and see what is possible

    My early thoughts are:
    1.There may be a command available to simply break the links, but the obvious one does NOT work in Publisher
    Please Login or Register  to view this content.
    (... but works in PowerPoint!? )

    2. Open the Publisher files in Excel via a menu and VBA
    - sounds silly, but that would work (see previous post)
    - BUT that would be more tricky (but still possible, I think) if anyone other than you needs to open then

    3. Build publisher files (via VBA) "on the hoof" each time, which involves telling VBA
    - where to put the images
    - pasting each image without linking
    - BUT this makes the VBA code more complicated ESPECIALLY if different sheets have different instructions

    Edit ...
    I have started a new thread specifically targeting breaking links with VBA in publisher
    - so far nobody has offered a solution
    - I will not attempt anything else for 72 hours to allow time for response on that thread
    - in the meantime Do you have any thoughts on this?

    Thanks
    Last edited by kev_; 01-08-2018 at 07:05 AM.

  14. #14
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Accessing data from excel to use within a Publisher macro

    So far there are no replies on my other thread

    Have you tested the code in post#12?
    Does it achieve what you want?

  15. #15
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Re: Accessing data from excel to use within a Publisher macro

    i am very sorry... just back today.. been out of the country....... looking at all of this great effort now....... will revert soon.....

  16. #16
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Re: Accessing data from excel to use within a Publisher macro

    Kev-
    1-so What i need to do first would be to take my existing 30 publisher files and put them all in the same directory
    2-change the names in the excel doc (which will also reside in the same location as the publisher files) v1-9 on each page.

    wow.. this work is amazing!!!!!

  17. #17
    Forum Contributor
    Join Date
    05-05-2004
    MS-Off Ver
    Office 365
    Posts
    651

    Re: Accessing data from excel to use within a Publisher macro

    BTW its OK to overwright the old data as the pdf is really all i need as a copy. so breaking the links is not needed.

  18. #18
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Accessing data from excel to use within a Publisher macro

    You do not need to move your files
    (I was lazy - used 1 folder)
    - you can set a different folder on each worksheet

    If each publisher file is in same folder as its matching PDF, then the code should work
    - I assume that you have 30 folders
    - set the correct folder on each sheet

    If Your files are organised differently tell me and we can probably change the VBA
    Last edited by kev_; 01-11-2018 at 12:46 PM.

  19. #19
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Accessing data from excel to use within a Publisher macro

    BTW its OK to overwright the old data as the pdf is really all i need as a copy. so breaking the links is not needed
    Do you need to save the 30 publisher files?
    Why don't you not simply generate the 30 PDF's from the 30 master publisher files?
    (you need to retain anything, you could simply archive a copy of the Excel file each month)
    Last edited by kev_; 01-11-2018 at 01:23 PM.

+ 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. Is it possilble to transfer data from Excel to Publisher?
    By markhuges in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 10-24-2011, 06:40 AM
  2. Accessing an outlook message via an excel macro
    By jeskit in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-10-2011, 06:38 AM
  3. export data from excel to publisher
    By jimb0693 in forum Excel General
    Replies: 1
    Last Post: 11-06-2009, 12:35 PM
  4. Matching publisher code with the publisher
    By bearaman in forum Excel General
    Replies: 2
    Last Post: 03-19-2008, 01:13 PM
  5. [SOLVED] Mail Merge Excel Data with Publisher for 4 up postcards
    By azsuns in forum Excel General
    Replies: 0
    Last Post: 04-27-2006, 07:10 PM
  6. [SOLVED] Merging excel office data into a publisher office project(Australi
    By Shirl in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 04-16-2006, 04:20 AM
  7. Problem accessing MS Excel macro from VB6.0
    By ourspt in forum Excel General
    Replies: 0
    Last Post: 01-28-2005, 06:17 AM
  8. Problem accessing MS Excel macro from VB6.0
    By ourspt in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2005, 06:16 AM

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