Excel - .pdf file not working in UserForm
Asked By Phil H
17-Mar-10 07:59 AM

SITUATION: want to place a .pdf file in a UserForm so when a user clicks a
CommandButton in a worksheet, the UserForm comes up displaying the .pdf file
and the user can scroll through the pages.
WHAT???S BEEN DONE:
1. UserForm3 created.
2. Adobe AcroPDF1 control inserted/confirmed in UserForm ??? from Toolbox.
3. CommandButton1 inserted in worksheet.
4. The following code inserted in Module1 [thanks go to Jacob Skaria on
MSDN]:
Private Sub CommandButton1_Click()
With Me.AcroPDF1
.LoadFile "S:\.........\DTM-09-007.pdf" [the file on local
share drive]
.setShowToolbar (False)
.gotoFirstPage
End With
End Sub
RESULT: On clicking CommandButton1:
1. Error message: ???Compile Error:???
a. ???Method or data member not found???
b. Private Sub line yellow highlighted
c. .AcroPDF1 cited (highlighted blue)
REQUEST:
1. Resolve compile error.
2. Have the .pdf file imbedded in the Excel workbook so when the workbook
is used by others outside the local share drive (.pdf file not accessible),
the .pdf file will come up and be operable in the UserForm.
Error
(1)
Excel
(1)
Adobe
(1)
Worksheet
(1)
Workbook
(1)
VB
(1)
AcroPDF1
(1)
SetShowToolbar
(1)
Peter T replied to Phil H
You say CommandButton1 is on a worksheet and the AcroPDF1 is in a userform
but that is completely at odds with your code. Assuming the setup is as you
describe, try something like this -
Private Sub CommandButton1_Click()
Dim sFile As String
sFile = "S:\.........\DTM-09-007.p"
With UserForm1.AcroPDF1
.LoadFile sFile
.setShowToolbar False
End With
UserForm1.Show
End Sub
Regards,
Peter T
Phil H replied to Peter T
Peter,
Thanks for your help. I did as you suggested and progress made. The
compile error is gone and UserForm3 appears in the worksheet; however, there
is a blank white rectangular space in the middle of the UserForm, where page
one of the pdf file should appear. In the VB Forms editor, UserForm3 shows
the same white space with the Adobe PDF (AcroPDF1) icon. I have inserted the
complete file path (it???s accurate) in the code. Any idea what to do next?
Also, is Module1 the correct place for the code?
Thanks, Phil
Peter T replied to Phil H
Not sure why you get the white space, seems to work fine for me. Try loading
the pdf as the form is shown. The user will see the form load first then a
slight pause while the pdf is loaded, rather than the other way round.
'' userform code
Public gsFile As String
Private Sub UserForm_Activate()
With Me.AcroPDF1
.LoadFile gsFile
.setShowToolbar False
End With
End Sub
' worksheet module of the sheet with the CommandButton
Private Sub CommandButton1_Click()
Dim sFile As String
sFile = "S:\.........\DTM-09-007.pdf"
UserForm1.gsFile = sFile
UserForm1.Show ' this triggers the form's Activate event
End Sub
Well, the CommandButton's click event must be in the worksheet module of the
sheet that contains the CommandButton. Code in the event could go on to call
other code in normal modules.
Regards,
Peter T
Phil H replied to Peter T
Thanks, Peter - will work on it tomorrow and get back. R/Phil

Excel Help on Interest calculation? Advanced maths ? This worksheet works, for one scenario. Need help, please, for the second scenario Initial deposit £250, invest column). I'm not an advanced mathematician. Have a friend, who is, he created the Excel formulae from the British Banking Association;s (hugely complex) mathematical formulae. HELP ! please? Hi Silvabod, You're making this hard for yourself. Check out Excel's financial functions. Cheers - - macropod [MVP - Microsoft Word] - -- -- -- -- -- -- -- -- -- -- -- -- Macropod, thanks for the suggestion - unfortunately there isn't a pre-formed Excel financial function for posted "problem" scenario. ACCRINT is close, but unless "periods" can be modified 00" after 365 iterations - I'd be happy with + / - £1.00 difference. Per Google search "Excel ACCRINT", ACCRINT gives different results for the same data, depending on which "flavour" of Excel is used. I need mathematical accuracy, not an approximation. Can you help further, please? Silvabod holidays into your calculations, you're really looking at a highly customised version of What Excel does. I suppose you could construct formulae to do that, but a UDF might be
Excel Deleting 63, 886 Blank Rows Under My Data I am working on an excel file in which I currently have data in 1, 650 rows and there are blank my data that randomly appeared when I copy and pasted my data to a new workbook. When I highlight a single blank row or many blank rows beneath my data and because my scroll bar had become all but useless- please help! Thanks! hi i think excel has lost it is used range reference. see this site to reset. http: / / www.contextures the sheet. Technically, what you're actually doing is resetting the *used range*. - - Biff Microsoft Excel MVP Thanks for the website- I tried highlighing the rows and deleting and that didn anything? Also, every time I open and close this file, this message pops up : Compile error in hidden module: DistMon- - think that has anything to do with it?? Thanks!! Thanks for direction in that area would be helpful thanks! I just tried both methods in an Excel 2007 file and both methods worked. I am kind of suspicious of this: - - Biff Microsoft Excel MVP For the Distmon error message. See KB article http: / / support.microsoft.com / default.aspx
Excel putting a picture onto a userform without using the vba window. I have userforms which noticed somebody had pasted something about the user pasting the imagefrom the clipboard into the workbook which is exactly what I dont want to do. I have had a look at ChemDraw 2) user draws a selection box around structure and presses ctrlC 3) user opens excel file 4) user activates form 5)user pastes (ctrlV) structure into some sort of dialog box / text box / other control?? on the form- such a control may not exist 6) Excel appends the copied image as a picture onto another predefined user form (or the same show the form modeless Sub ShowForm() UserForm1.Show vbModeless End Sub Run the form, activate Excel, select some cells, (in Excel97-2003) hold Shift and select Edit - CopyPicture, try both Picture in particular how do you know user has copied a suitable picture before opening your workbook (which could destroy the clipboard depending on other factors). To at least get some idea user may elect to copy a structure from a pdf using the marquee tool in adobe reader and paste that (for example; if they dont have Chemdraw). Roger Glad it seems to file and load from file. Oops, my fault, not sure how such an elementary error crept in! In the userform code (as posted last time) replace CommandButton1_Click with the following
Excel Create PDF from XLS by VB Code using PDFMaker include Bookmarks Hi I want help I use following code VB code in Excel to create a pdf file. Public Sub CreatePdf() On Error GoTo err_cmdCreatePdf_Click 'Creates .pdf from current worksheet. 'Derives path & file name from worksheet properties. Dim strPsFileName As String Dim strPdfFileName As String Dim strPsFileNameDoubleQuotes As String Dim strPdfFileNameDoubleQuotes Define the postscript and .pdf file names. 'Briefly displays form to let user know the adobe file is being created. 'UserForms.Add("ShowWorking").Show ' Saves the workbook before creating .pdf ActiveWorkbook.Save 'ActiveWorkbook.Name property is the worksheet file name including path & .xls extension strfullActiveWorkbookName = ActiveWorkbook.FullName ' Substring commands to extract path of