Consulting

Results 1 to 2 of 2

Thread: Saving a file vy referencing a cell and using RDB Create

  1. #1
    VBAX Regular
    Joined
    Aug 2012
    Posts
    13
    Location

    Saving a file vy referencing a cell and using RDB Create

    Hello,

    I need help with the following code. I want to create a PDF and save it to a fixed location using a cell as the file name. The area hilited in red is where I am having troubles. Can someone help? If I remove the range the code works perfect. Same is true if I remove the file location name.

    [vba]
    Sub RDB_Worksheet_Or_Worksheets_To_PDF()
    Dim FileName As String, fname As String


    If ActiveWindow.SelectedSheets.Count > 1 Then
    MsgBox "There is more then one sheet selected," & vbNewLine & _
    "be aware that every selected sheet will be published"
    End If
    'Call the function with the correct arguments
    'Tip: You can also use Sheets("Sheet3") instead of ActiveSheet in the code(sheet not have to be active then)
    FileName = RDB_Create_PDF(ActiveSheet,"O:\J\Activity Report\Activity Report\ & Range("C27").Value", True, False)
    'For a fixed file name and overwrite it each time you run the macro use
    'RDB_Create_PDF(ActiveSheet, "C:\Users\Ron\Test\YourPdfFile.pdf", True, True)
    If FileName <> "" Then
    'Ok, you find the PDF where you saved it
    'You can call the mail macro here if you want
    Else

    End If
    End Sub
    [/vba]

  2. #2
    VBAX Expert CatDaddy's Avatar
    Joined
    Jun 2011
    Posts
    581
    Location
    change
    [VBA] FileName = RDB_Create_PDF(ActiveSheet,"O:\J\Activity Report\Activity Report\ & Range("C27").Value", True, False)[/VBA]

    to

    [VBA] FileName = RDB_Create_PDF(ActiveSheet,"O:\J\Activity Report\Activity Report\" & Range("C27").Text, True, False)[/VBA]
    ------------------------------------------------
    Happy Coding my friends

Posting Permissions

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