Please could you check my code

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Evening,
The code in use is shown below.

I ask for it to be checked as it doesnt seem to flow smoothly also if i move the cursor away from the MsgBox i see the cursor going around & around all the time



Rich (BB code):
Private Sub Generate_Pdf_Click()
  Dim sPath As String, strFileName As String
  strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR SCREEN SHOT PDF\" & Range("G13").Value & ".pdf"
  If Dir(strFileName) <> vbNullString Then
  MsgBox "GENERATED PDF " & vbNewLine & vbNewLine & Range("G13").Value & vbNewLine & vbNewLine & "WAS NOT SAVED AS IT ALLREADY EXISTS", vbCritical + vbOKOnly, "GENERATE PDF FILE MESSAGE"
  Exit Sub
  
  End If
    With ActiveSheet
    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
  MsgBox "PDF HAS NOW BEEN SAVED", vbInformation + vbOKOnly, "GENERATE PDF FILE MESSAGE"
  
  End With
  
  sPath = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR SCREEN SHOT PDF\"
  strFileName = sPath & Range("G13").Value & ".pdf"
  If Dir(strFileName) <> vbNullString Then
    ActiveWorkbook.FollowHyperlink strFileName
  End If
  
  InvoiceClearSheetQuestion.Show

End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
... also if i move the cursor away from the MsgBox i see the cursor going around & around all the time

That is normal behavior. It indicates that it is waiting for a response to the MsgBox.
 
Upvote 0
Hi,
Well I can only say that on various sheets I have many message boxes that I use & none of them do what I’ve mentioned in my first post.

Are you saying you’ve looked at my code & it’s all ok ?

Thanks.
 
Upvote 0
Hmm, it appears I was mistaken since I can't duplicate an example. I know I have seen the behavior before many times. I guess disregard my previous post. Sorry.
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,742
Members
448,989
Latest member
mariah3

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