473,836 Members | 1,358 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Export a report to the current desktop in pdf format

547 Contributor
I would like to always export a particular report as a pdf document to the current "desktop" of that specific PC, without hardcoding the "user" of that computer in the vba. My current vba is:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "Drugusage", acFormatPDF, , True
Any suggestions please
Dec 14 '12 #1
12 14996
Seth Schrock
2,965 Recognized Expert Specialist
I don't know if this works in VBA, but in windows scripting the %username% takes the place of the user name in the file path. It might be something to look into.

Edit: If this is something that will have to work across Win XP & 7, just know that the file path is different for each OS. XP uses Documents and Settings while 7 uses Users. I'm not sure how to tell the database which path to use. I normally make a folder on the C:\ drive and then make a shortcut on the desktop to that folder if I need to. It simplifies the VBA end.
Dec 14 '12 #2
547 Contributor
It will be for different windows 7 machines only.
Dec 14 '12 #3
Seth Schrock
2,965 Recognized Expert Specialist
Okay. I don't have a test database to work with, but you could try the following:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "Drugusage", acFormatPDF, "C:\Users\%username%\Desktop\Drugusage.pdf", True
If that doesn't work I have another idea, but lets start with that for now.

--**DOES NOT WORK**-- Moderators can remove post.
Dec 14 '12 #4
Seth Schrock
2,965 Recognized Expert Specialist
I remembered where I had used the DoCmd.OutputTo in one of my databases so I tested my theory on that and what I had in my previous post didn't work. So I tested my other idea and it did work. Here it is:
Expand|Select|Wrap|Line Numbers
  1. Dim strUserName As String, strPath As String
  3. strUserName = Environ("username")
  4. strPath = "C:\Users\" & strUserName & "\desktop\Drugusage.pdf"
  6. DoCmd.OutputTo acOutputReport, "Drugusage", acFormatPDF, strPath, True
I had to manually put in your information so you might check that I have typed everything correctly.
Dec 14 '12 #5
547 Contributor
Thx a Seth it works great !!! I have also tried it for a database of mine
Dec 14 '12 #6
Seth Schrock
2,965 Recognized Expert Specialist
Just curious, are you working with Neelsfer on this?
Dec 14 '12 #7
547 Contributor
Seth you are a star. It is working as i expected it to work
Dec 14 '12 #8
Seth Schrock
2,965 Recognized Expert Specialist
Not a problem neelsfer. It was actually exciting for me because this is one of just a few times where I have been able to take pieces from other puzzles and put them together and make a whole new picture :) I have used different part of my code in separate databases, but never together so it was nice to see it all come together so nicely.
Dec 14 '12 #9
5,501 Recognized Expert Moderator Expert
YEA Seth!
It was only a matter of time!

As for the environment variable: "%USERPROFILE%\ Desktop"
It has been this since windows97 and continues thru windows7. I have not had a hand's on with windows8. I typically use this to place a document in the users' document folder.

As for a longer term solution (and something I've considered moving to): http://msdn.microsoft.com/en-us/libr...ffice.10).aspx I believe that ADezii will have a better handle on that method.
Dec 14 '12 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Olya | last post by:
I'm developing reports with using Crystal Report Viewer on ASP.NET. After I have report done I try to export it to .PDF format and get the following error: "Error in File C:\DOCUME~1\4974-W\ASPNET\LOCALS~1 \Temp\temp_2bc3fd27-1cdb-47af-9cf5-1795a1d8aff0.rpt: Access to report file denied. Another program may be using it." The code I use: Dim crDiskFileDestinationOptions as New
by: Majstor | last post by:
Does anybody know how to export Report in Word, Excel or HTML with pictures (Access 2000)? I don't use snapshot format.
by: Li Pang | last post by:
Hi, I built a web form to display a crystal report in web, every thing work properly. I added then a button to display the report in the embedded adobe reader by using the below codes: Dim oStream As New MemoryStream oStream = crReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.WordForWindows) Response.Clear()
by: jpr | last post by:
Friend, I am using a code to export data from a table to a word document using bookmarks and have a problem with a date format. When I export a field that is a mm/dd, in my word doc it shows up with the format mm/dd/yyyy. Is there a way I can export to show the format mm/yyyy? This is the code: objWord.ActiveDocument.Bookmarks("purgedate").Select If Err.Number = 0 Then
by: Mariana | last post by:
Hello, I am exporting reports in pdf format from .net 2005 . The export is working fine; however the user values of stored procedure parameters does not show in the report. What do I need to do in order to see the parameters value in the report? The report has a report parameter "reportTitle" and i see the value in the report. It has also another 2 stored procedure parameters @BeginDate and @EndDate. The values are entered be the user;...
by: Joe Schmo | last post by:
Is there any way to export an Access Report, including the format, into a Word document - other than printing to a PDF.
by: 1q2w3e4r5t6y7u8i | last post by:
Hi, I am printing an invoice through the following code: dim cr as new crystalreport1 cr.PrintToPrinter(1, False, 1, 1) the problem is that the complete paper cames out. I want to print till the text exists else stop printing such as printing in forpro I had saw the following forum
by: muddasirmunir | last post by:
is there any way or third party utility which can export our data report to pdf format i am usinig vb6 i know crystal report can do that but i had a project with data report is there any way to export data report to pdf format
by: ttfitz | last post by:
I have an application developed in Access 2000, to be distributed as an MDE. For those folks without Access, they install the free Access 2007 runtime. For the most part, this seems to be working well. However, when viewing a report in Preview mode, if you right-click and select the "Export" option (I have defined a custom menu which includes the standard "export" option), when using the runtime you immediately get an error, which says,...
by: ghiey | last post by:
hi to all, i have searched for a solution regarding exporting access 2007 reports to excel file. i have converted to access 2007 my database from access 2003. i guess microsoft omitted the ease of exporting to excel in 2007 where it works perfectly on 2003. my problem is. is there a way that i can export report to excel. i have already installed the service pack 2 of ms. office 2007. it works on xp but in windows 7, not.
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.