Variable file location

ahovander1213

New Member
Joined
Oct 13, 2018
Messages
10
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
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top