.pdf'ing code - type mismatch error

Robby87

Board Regular
Joined
May 9, 2008
Messages
128
Sub MakePDFNS()

ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Adobe PDF:", Collate:=True
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 2
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Filename = "G:\Group\Gfin\Rob_Young\" & ActiveSheet.Range("NS!C3:C4").Value & "NS"
SendKeys Filename & "{ENTER}", False

End Sub

this code leaves a sour taste in my mouth because it has been almost 2 weeks now and still it is failing. Am I missing something important in this VB code?
The line giving the Type Mismatch Error is "Filename = "G:\Group..." "

Please help?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
This is wrong.
Code:
Range("NS!C3:C4")
It returns the values from both C3 and C4.

It might even return an array, but it definitely doesn't return a single string value.:)
 
Upvote 0
Most recent version of code...

Sub MakePDFNS()

ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Adobe PDF on Ne01:", Collate:=True
Filename = "G:\Group\Gfin\Rob Young\" & ActiveSheet.Range("NS!Q3").Value & "NS"
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 4
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime

SendKeys Filename & "{ENTER}", False

End Sub

Still having the problem of it not even coming close to naming my file.
Has anyone ever dealt with this issue? Have read other threads on here that have solutions for the problem, but I can't make a single one work in my case... Excel 2003, Adobe Reader 8.... I am wondering though...

To circumvent the whole complicated code system (unless i'm talking out my *** again) is there a line of code that can be used to select the save window, or activate it? I don't know where I would go from there, but at least it would add another branch of reasoning to the issue.

Please help again!!!

Thanks everyone for looking :)

- Rob
 
Upvote 0

Forum statistics

Threads
1,214,973
Messages
6,122,534
Members
449,088
Latest member
RandomExceller01

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