VBA Open file and convert to PDF
Results 1 to 7 of 7

Thread: VBA Open file and convert to PDF
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Apr 2019
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA Open file and convert to PDF

    Hello, a real novice here so excuse the probably simple question but I cannot locate an answer.

    I have a master workbook which contains lots of file paths to other workbooks. These locations change every month so to get around it I have a sheet which automatically updates the file paths each month.

    However I am struggling to get VBA to read that file path which is specified in the cell.

    This is a smaller example but I have specified B10 and B11 as the path to open as they will always change but what code do I need to do which say Open "filepath1"

    Sub Convert()


    Dim filepath1 As String
    Dim filepath2 As String


    filepath1 = Range("B10").Value
    filepath2 = Range("B11").Value

    Workbooks.Open (filepath1)


    End Sub

  2. #2
    New Member
    Join Date
    May 2019
    Location
    Indiana, USA
    Posts
    46
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Open file and convert to PDF

    Hi Cagey93,

    This code works for me. What do the values of those cells look like? It should be a simple file path to the worksheet you want to open. Example:

    C:\Users\[USER_HERE]\Downloads\excel\New Microsoft Excel Worksheet.xlsx

    No quotes or anything in the cell.
    Last edited by RoryA; May 22nd, 2019 at 11:42 AM. Reason: Remove unnecessary quote

  3. #3
    New Member
    Join Date
    Apr 2019
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Open file and convert to PDF

    Hello,

    the file path is as follows which I have triple checked is correct
    "\\companyname\Treasury\D&I\MACRO TEST\Excel 1\April\TESTERApril.xlsx"

    obviously the company name is an actual name but I cant post that on here.
    Last edited by RoryA; May 22nd, 2019 at 11:42 AM.

  4. #4
    New Member
    Join Date
    May 2019
    Location
    Indiana, USA
    Posts
    46
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Open file and convert to PDF

    Are the quotes included in the cell? If they are, remove them.
    Last edited by RoryA; May 22nd, 2019 at 11:42 AM.

  5. #5
    New Member
    Join Date
    Apr 2019
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Open file and convert to PDF

    No they aren't sorry I just put that to highlight the that from the rest of the reply. I have tested the file path is correct by copying it into an explorer window and it loads it no problem.

  6. #6
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    27,058
    Post Thanks / Like
    Mentioned
    461 Post(s)
    Tagged
    46 Thread(s)

    Default Re: VBA Open file and convert to PDF

    Does B10 contain the full path & filename?
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  7. #7
    New Member
    Join Date
    Apr 2019
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Open file and convert to PDF

    Solved it silliest mistake I had moved it to another cell and didn't update the cell it was looking at, been staring at it so long but missed the obvious one.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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