Please can you cand my code for an error

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Hi,
Please can you advise what ive done wrong with this line of code.
Basically the saved file is of pdf format, name is taken from cell B3 & date is taken from cell E3 but merged E3:K3


When using this line of code the file is saved as pdf & customers name all fine.
Rich (BB code):
strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\" & .Range("B3").Value & ".pdf"

However when i use this line of code which pulls the dat from cell E3 i just see an error message, unable to save.
Rich (BB code):
strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\" & .Range("B3").Value & " " & .Range("E3").Value & ".pdf"
 
Noted & now i use thanks.
That solved that & saves ok.

Once the file is saved the next part of the code opens the pdf so i can print but this isnt now opening.

This is the code, do i need to alter it in some way ?
Saved file example TOM JONES 16-03-2023.pdf

Rich (BB code):
  End With
  
  sPath = "C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\"
  strFileName = sPath & Range("B3").Value & " " & Range("E3").Value & ".pdf"
  If Dir(strFileName) <> vbNullString Then
    ActiveWorkbook.FollowHyperlink strFileName
  End If

    
 
End Sub
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Which is alright if the OP knows they are looking for illegal characters and knows what characters are illegal
And if they didn't know that, then they could post the output and eliminate any guessing. As I said, it's basic trouble shooting that too few people make use of.
 
Upvote 0
And if they didn't know that, then they could post the output and eliminate any guessing. As I said, it's basic trouble shooting that too few people make use of.
Post #4 mentions i was out at the time so couldnt do what you advised but then the next reply jogged my mind & i then had a thought
 
Upvote 0
I get it. My point is that if you did the basics you probably wouldn't have had to post in the first place. If you did the basics and still didn't see the problem, then your first post should have included the output from the immediate window, thereby exposing the problem right away rather than having to post back and forth with questions and answers. Not trying to be argumentative here; just trying to help you to help yourself for next time.
 
Upvote 0
See screenshot & read it please
 

Attachments

  • EaseUS_2023_03_16_17_55_23.jpg
    EaseUS_2023_03_16_17_55_23.jpg
    30.9 KB · Views: 11
Upvote 0
This is the code, do i need to alter it in some way ?
The part in red needs to match the amended code in the save part

Rich (BB code):
  sPath = "C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\"
  strFileName = sPath & Range("B3").Value & " " & Range("E3").Value & ".pdf"
 
Upvote 0
Done.
I didnt remove the full stops.

This now works,may thanks.

Rich (BB code):
        sPath = "C:\Users\Ian\Desktop\REMOTES ETC\DISCO II CODE\DISCO II PDF\"
        strFileName = sPath & Range("B3").Value & " " & Format(Range("E3").Value, "dd-mm-yyyy") & ".pdf"
 
Upvote 0

Forum statistics

Threads
1,215,365
Messages
6,124,513
Members
449,168
Latest member
CheerfulWalker

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