Variable file location
Results 1 to 2 of 2

Thread: Variable file location
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Oct 2018
    Location
    Albuquerque, NM
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Variable file location

    I have a folder that is a template for multiple forms.
    I wrote a code that open the forms and publishes to another location. Works fine.

    My problem is that since this is a template that my users use to make a new file the location changes

    The area in red font is my issue.

    my simplistic example is that I have folders on Desktop as template. Working file is copied to My Documents

    As always any help is greatly appreciated

    Workbooks.Open Filename:= _
    "C:\Users\alanh.CASNM\Desktop\CD - Al Test\05 Forms and progamming\QC Design.xlsm" _
    , UpdateLinks:=3
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "\\A-ca-APP01\SmartSearchImport\Order\29\QCDESIGN.pdf" & ActiveSheet.Range("e2:e2"), Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    False
    ActiveWorkbook.Save
    ActiveWorkbook.Close

  2. #2
    Board Regular
    Join Date
    Feb 2012
    Posts
    870
    Post Thanks / Like
    Mentioned
    9 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Variable file location

    If they save the file in the same location as the file they are opening you could use ThisWorkbook.Fullname.

    Just update "Your book name.xlsm"

    Code:
    Sub findabove()
    
    
    Workbooks.Open Filename:= _
    Left(ThisWorkbook.FullName, InStr(ThisWorkbook.FullName, "Your book name.xlsm") - 1) & "05 Forms and progamming\QC Design.xlsm" _
    , UpdateLinks:=3
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "\\A-ca-APP01\SmartSearchImport\Order\29\QCDESIGN.pdf" & ActiveSheet.Range("e2:e2"), Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    False
    ActiveWorkbook.Save
    ActiveWorkbook.Close
    
    
    End Sub

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
  •