Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-13-2014, 08:19 AM
ozman86 ozman86 is offline Error in VBA code Windows 7 64bit Error in VBA code Office 2010 64bit
Novice
Error in VBA code
 
Join Date: Nov 2014
Posts: 4
ozman86 is on a distinguished road
Default Error in VBA code

Compile Error:


Syntax Error


the above error is coming for the below code . it happens when inject the Day condition

Private Sub TestFileExistence()


If FileFolderExists("\\cf3.pepsico.pvt\psra\Output\BI 4\Exec Dollars - Current Period.pdf")and
weekday(date) = 2 Then

Range("A1").Value = "X"

Else

Range("A1").Value = "!"

End If
End Sub
Reply With Quote
  #2  
Old 11-13-2014, 08:24 PM
macropod's Avatar
macropod macropod is offline Error in VBA code Windows 7 64bit Error in VBA code Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I assume you have a function 'FileFolderExists' somewhere, since that's not a native VBA function.

Try:
Code:
Private Sub TestFileExistence()
If Dir("\\cf3.pepsico.pvt\psra\Output\BI 4\Exec Dollars - Current Period.pdf", vbNormal) <> "" Then
  If Weekday(Date) = 2 Then
    Range("A1").Value = "X"
  Else
    Range("A1").Value = "!"
  End If
Else
  Range("A1").Value = "!"
End If
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-27-2014, 08:10 AM
Bruno Campanini Bruno Campanini is offline Error in VBA code Windows 8 Error in VBA code Office 2013
Novice
 
Join Date: Nov 2014
Posts: 19
Bruno Campanini is on a distinguished road
Arrow

Quote:
Originally Posted by macropod View Post

Quote:
I assume you have a function 'FileFolderExists' somewhere, since that's not a native VBA function.

Try:
Code:
Private Sub TestFileExistence()
If Dir("\\cf3.pepsico.pvt\psra\Output\BI 4\Exec Dollars - Current Period.pdf", vbNormal) <> "" Then
  If Weekday(Date) = 2 Then
    Range("A1").Value = "X"
  Else
    Range("A1").Value = "!"
  End If
Else
  Range("A1").Value = "!"
End If
End Sub
Don't waste paper and ink... it's a matter of logic:

If Dir("\\cf3.pepsico.pvt\psra\Output\BI 4\Exec Dollars - Current Period.pdf", vbNormal) <> "" And Weekday(Date) = 2 Then
[A1] = "X"
Else
[A1] = "!"
End If

Bruno
Reply With Quote
  #4  
Old 11-27-2014, 01:06 PM
macropod's Avatar
macropod macropod is offline Error in VBA code Windows 7 64bit Error in VBA code Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You evidently don't understand the issue. The OP already had that and it gives an error when used that way.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
error code 30029-4 zignaasa Office 0 05-24-2014 10:07 PM
Error in VBA code Error Code 5453 Word has finished searching the document Charles Kenyon Word VBA 2 05-17-2012 11:18 AM
Code Error - Hiding comments and revisions silvrwoman Word VBA 6 03-24-2012 10:15 PM
Error in VBA code Microsoft Code Error 1907 JHauglid Office 1 02-27-2012 12:15 AM
Error code 0x800CCC80 Kevin Outlook 1 03-18-2011 07:20 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:44 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft