Saving to a Dropbox location

kallabungo

New Member
Joined
Aug 13, 2013
Messages
17
Hi all, i'm having a problem trying to use my existing macro coding to work across multiple computers accessing the same files hosted on Dropbox.

Currently I have created macros that will generate consecutive invoice numbers and then export the file as a PDF to a destination file with a prefix before the invoice number, which has worked flawlessly for years.

Now, I need to relocate these files to Dropbox so that multiple users can access from different computers. I have no doubts that the coding required in this is very simple but I have little to no knowledge of VBA and really need some help from someone that knows more than me.

So, this is the code that I am currently using.

Sub NextInvoice()
Range("H13").Value = Range("H13").Value + 1
Range("B24:H43, H15").ClearContents
End Sub
Sub SaveInvWithNewName()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\East Point Metals.DESKTOP-HFIK217\Dropbox\Invoicing\Credit Notes\Crn" & Range("H13").Value & ".PDF", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
NextInvoice
End Sub

Now the problem im experiencing is related to this;

C:\Users\Stuart\Dropbox\Invoicing\Credit Notes
C:\Users\Home\Dropbox\Invoicing\Credit Notes

These are 2 other folder paths from the other computers accessing these files. I've done some hard research and manipulation of code but cannot get it to work.

Ideally I'm looking for some coding that will pull the correct folder path off the current users computer and will insert it before the \Dropbox\Invoicing\Credit Notes so everything goes where it should.

Really appreciate any help that may be received.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
The code you need to use Environ("UserProfile")
For example
Code:
FullFileName = Environ("UserProfile") & \Dropbox\Invoicing\Credit Notes\Crn" & Range("H13").Value & ".PDF"
The use FullFileName in your ActiveSheet.ExportAsFixedFormat line.

Bye
 
Upvote 0
Hi Anthony thanks for taking the time to reply. I have tried so many different combinations of using the code you provided and keep getting "expected: end of statement" errors.

Are you able to help any further at all?
 
Upvote 0
I guess you are misung the "underscore" (_) character; if you list your macro probably we can help.
Copy the code from your macro and paste it into your next message (no retyping, please)

Bye
 
Upvote 0
Sub NextInvoice()
Range("H13").Value = Range("H13").Value + 1
Range("B24:H43, H15").ClearContents
End Sub
Sub SaveInvWithNewName()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"FullFileName = Environ("UserProfile") & \Dropbox\Invoicing\Credit Notes\Crn" & Range("H13").Value & ".PDF", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
NextInvoice
End Sub
 
Upvote 0
Well I have found the easiest way to get around this problem, although a little crude.

Just move Dropbox install location to C:\Dropbox - then do the same on the other computers that are accessing the files as their main hard drive are also C:\

Super easy!
 
Upvote 0
Instead of
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"FullFileName = Environ("UserProfile") & \Dropbox\Invoicing\Credit Notes\Crn" & Range("H13").Value & ".PDF", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False


use
Code:
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Environ("UserProfile") & "\Dropbox\Invoicing\Credit Notes\Crn" & Range("H13").Value & ".PDF", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False

Bye
 
Upvote 0
I copied and pasted the code exactly as you said however i get a runtime 1004 error, the document is unable to save.

Thanks for your time on this though, really appreciate it.
 
Upvote 0
Well, I answered to your question:
"Ideally I'm looking for some coding that will pull the correct folder path off the current users computer and will insert it before the \Dropbox\Invoicing\Credit Notes so everything goes where it should"

I think the problem is with the user that saves in "C:\Users\East Point Metals.DESKTOP-HFIK217\Dropbox\Invoicing\etc etc": does his UserProfile point to "C:\Users\East Point Metals.DESKTOP-HFIK217"?

For debug purpose, add this line in this position:
Code:
Debug.Print Environ("UserProfile") & "\Dropbox\Invoicing\Credit Notes\Crn" & Range("H13").Value & ".PDF"   '<< THIS LINE IN THIS POSITION
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Environ("UserProfile") & "\Dropbox\Invoicing\Credit Notes\Crn" & Range("H13").Value & ".PDF", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False

Then try running the code.
When the error arise use the option "Debug" to see which is the highligthed instruction.
At that point, press Contr-g to open the "VBA Immediate" window: see what is the file name listed and check that the path exists.
Insert your findings in your next message: the line in error is the ActiveSheet.ExportAsFixedFormat one? Which is the file name shown and does the path exists?

Bye
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

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