Print button didn't save the PDF file at a shared path, and no error logged - vba

I have an Excel macro that uses SAP for printing data in pdf format.
Steps:
it access the SAP transaction which provides a table with the necessary information
it press Print button (from the Menu Bar of SAP)
then Print window appears (from here it is selected Microsoft Print To PDF option and then it is pressed OK button)
Save As window appears (complete the path and filename: \S\BC....\outputName)
then Save button it is pressed
then no error happens
But if I access the path folder "\S\BC....", nothing happen, there is no file saved. BUT, if we look in "Date modified" property of the folder, it is modified in accordance with the last saving time.
Also, I mention that if I'm trying to write the pdf file on local folders, not network shared folders (example: a desktop folder: C:\Users\mariah\Test), macro works.
Also, I mention that user can Read&Write at the shared path \S\BC....\
Please help me to find the cause of this issue.

A VBA macro only does what you are allowed to do manually. Can you manually save the file in the shared path without the macro?
Is the common path really \S\BC...\ or \ \S\BC...\ ?
Regards,
ScriptMan

Solution proposed by the OP in this comment:
IT WORKS if I save the file on "C:\Users\UserName" and then cut it to shared path "S\BC...". So I've implemented code that saves the file in a path and then copy it to another path and then I deleted it from the first path (such that user never knows that I copy the file in other destination than desired destination).

Related

Excel on Mac. Cannot open IQY file in Data/Get External Data/Run Web Query

I am running Excel version 16.45 on Mac.
I have created a .iqy and saved it in the Queries directory alongside certain templates which were already there.
I go to Data/Get External Data/Run Web Queries. While the templates are accessible, my file is visible but greyed out (same thing happens if I save the file in a different directory).
Would anyone be able to help?
According to your information, I would like to confirm whether the issue occurs when you follow the steps as below:
1.Create a Word file, paste the web URL.
2.Save the Word as .iqy with .txt format.
3.Choose MS-DOS as coding.
4.Create an Excel file and click "Data >Get External Data >Run Web Query (Or Run Saved Query) " of the Bar
I was able to address the issue as follows.
When navigating to the relevant directory with Finder, the '.iqy' file appears to be appropriately named (as per Image 1).
In fact, if you reach the file in Terminal, the file is saved as '.iqy.txt'.
So all I had to do is rename the file, simply removing the '.txt' string at the end.
Screen you see when navigating in Finder

Extract an Outlook attachment from the clipboard

I'm trying to access Outlook attachments from clipboard using VBA to further process the file.
The user copies an attachment to the clipboard (Right click -> Copy), opens PowerPoint, clicks a buttons and gets the presentation inserted a the end of the document.
The key part seems to access the PowerPoint file in the clipboard an save it on the file system.
Can someone help and provide a sample code for this using VBA in PowerPoint?
Many thanks!
I've found a way achieve it.
Getting filenames: Solution has been posted here: http://www.access-o-mania.de/forum/index.php?topic=17045.15
Getting the content
file size in clipboard can be obtained by GlobalSize(handle)
pointer the by GlobalLock(handle)
content using CopyMemory(destination, source, length)
Look at the clipboard contents with an app like ClipSpy. Since there is no physical file to be copied, the full file path is not included (no CF_HDROP format). But FileGroupDescriptor and FileContents formats are there.

Obtain the "absolute path to the workbook" from an .xls file

When I use the Excel "Document Inspector" on a particular .xls file to check for "hidden properties or personal information" it says:
The following document information was found:
* Absolute path to the workbook
How can I obtain the absolute path of the workbook from the file? If it needs to be done programmatically, I could use Java (e.g. Apache POI) or VBA.
I know where the file is currently saved, but what I want to extract is the absolute path to the workbook which is saved in the file I have. This is so I can know where it was saved by the author.
Here's what has happened to the file:
Someone authored it, saving it at some absolute filepath unknown to me
They uploaded it to a website
I downloaded it from the website
Excel indicates that the document contains the absolute path from step 1. I'm after this path, not the place I saved it at step 3 since I know that.
I can reproduced that warning message by simply creating an empty Excel file, added a formula, saved it as BIFF8 (.xls). The Document Inspector will then warn about the absolute path. ... but in my case, there was no filename inside the file.
A simple way to verify this, is to open the file in a hex-editor and search for a well-known save location (i.e. the location where a dummy/test file was stored) - this is either stored as ASCII or as 16-bit string, i.e. every odd byte is a character.
If you want to use the POI developer tools, you can use the following:
To list all Excel records:
java -cp poi-3.16-beta1.jar org.apache.poi.hssf.dev.BiffViewer file.xls
To list the document and summary properties:
java -cp poi-3.16-beta1.jar org.apache.poi.hpsf.extractor.HPSFPropertiesExtractor file.xls
To list any embedded objects beside the usual suspects SummaryInformation, DocumentSummaryInformation and Workbook:
java -cp poi-3.16-beta1.jar org.apache.poi.poifs.dev.POIFSLister file.xls
So after running the tools and recording the output, you can then remove the properties via the Excel Document Inspector and execute the tools again. The output can be diffed and you might find the culprit.
Assuming it is an .xlsx file rather than an older-style .xls file, you can
Rename the workbook as a .zip file
Look at the xl\workbook.xml "file" within the .zip file
and you will find the absolute path when last saved from Excel.
This is why it is not a good idea to share work-related spreadsheets with other people, unless you first clear out this sort of information.
I'm not sure how to find it in the binary format files.

Replacing the default File copy Dialog

i'm trying to replace the default file copy dialog with my own program, which I want to create with vb.net.
My problem:
Where can I enter my application path to start automatically (and parse arguments/paths) when the user copies and/or pastes files?
Thanks in advance!
In order to monitor a file path I would suggest using FileSystemWatcher Class. This will monitor a folder for any files that are copied and pasted to the location. There is a great example at the below link.
https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(v=vs.110).aspx

Make my applescript process specified files in the current directory?

I need to generate PDFs from word files regularly, and I'm getting tired of doing it by hand.
Manually, all I do is open a file, and click "Save as PDF". So, one would think applescript would be a nice easy way to do this. [If you have another approach than applescript, I'm open to it.]
I'm almost there, the following script works, except the full path is hard coded.
tell application "Microsoft Word"
open file "Macintosh HD:Users:me:repos:training:class:Activities:ActivityGuide.docx"
set doc to document "ActivityGuide.docx"
save as doc file name "Macintosh HD:Users:me:repos:training:class:Activities:ActivityGuide.pdf" file format format PDF
end tell
I need it to work for other people, on other machines, so the username and other parts of the path may change. If I could just do this from the current directory for the script, I'd be set.
I found this: Applescript to launch file from current folder?
tell application "Finder"
open file "somefile.txt" of folder of (file (path to me))
end tell
Which works for opening an app from the current directory in Word, via Finder, but I think I need to open it with an application of "Microsoft Word", if I'm going to use "Save As". But this method of opening doesn't work if I change the application for "Finder" to "Microsoft Word".
Any suggestions welcome.
[edit: clarity]
Try this
set x to path to me
tell application "Finder" to set tFile to (file "ActivityGuide.docx" of (container of x)) as alias
set newFile to (text 1 thru -5 of (tFile as string)) & "pdf"
tell application "Microsoft Word"
open tFile
tell document 1
save as file name newFile file format format PDF
close saving no
end tell
end tell
Another thing that might be helpful to you is under System Preferences:Keyboard:Shortcuts: App Shortcuts:All Applications
Make a shortcut that is named "Save as PDF..." assign the shortcut to command+P since most applications that is the shortcut for print, then just press it twice and it will prompt you to save it as a PDF (I got that tip from David Sparks) and depending on the application it will default to where the file was opened up from. You can also set that with the application Default Folder X.
Hopefully that is a bit more of a global solution for other problems but it looks like you already have the answer to this isolated problem.