problems downloading file w/ long name

georgec32

New Member
Joined
Mar 19, 2020
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hi all. I use Office 2016 on a Windows 10 platform. I have a rather complicated VBA code to download, parse, etc some files from a professional group. I ran into a problem when trying to download one particular file with a long name. My code downloads 5 files successfully (I've been doing this for a few years) but there is one file that is unique and has a very long filename. Could the length of the filename be the problem? I run through a loop with the same code for each file. I've put in breakpoints & msgboxes to verify that the file name & the directory is correct. If I use the file path given by my code, the file downloads properly, but not with the VBA code. I'm totally stumped. Thanks in advance for any guidance on this one!

This works with file A and B but not with file C. I checked the sub-directory and there is no file C:
tgt_path = cur_path & "\" & "R_temp.zip"
URLDownloadToFile 0, doc_link, tgt_path, 0, 0

where doc_link = web_addy & "/Tdoclist/" & Tdoc_file .. web_addy is the same for all files (I verified this manually for each doc)

doc_link is
Tdoc_file (File A name): TDoc_List_Meeting_RAN#86_200602.zip
Tdoc_file (File B name): TDoc_List_Meeting_RAN#87e_200602.zip
Tdoc_file (File C name:) tdocList_3GU_format_MMexport_2020-07-05_23h45.zip

The part of the code that's not working for this one file is below:
______________________________________________________________________________________________________________
Range("A:B").Select
Selection.Find(What:="*oc*ist*", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Tdoc_file = Trim(ActiveCell.Text)

'Stupid M$ VBA makes you replace the pound sign with "%23" (the character number for the pound sign) to download
Tdoc_file = Replace(Tdoc_file, "#", "%23")
doc_link = web_addy & "/Tdoclist/" & Tdoc_file
MsgBox (doc_link)
'now download the Tdoc file
tgt_path = cur_path & "\" & "R_temp.zip"
URLDownloadToFile 0, doc_link, tgt_path, 0, 0

Dim tgt_dir As String
tgt_dir = cur_path & "\"
zipped_file = tgt_path
zipped_dir = tgt_dir

Call UnziFile(zipped_file, zipped_dir)
______________________________________________________________________________________________________________

georgec32
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi and welcome to MrExcel.
Try turning off the autocorrect.

Below are the steps to turn off autocorrect:
  1. Click on the File tab.
  2. Click on Options.
  3. In the Options dialog box, select Proofing.
  4. Click on the ‘AutoCorrect Options’ button.
  5. In the Autocorrect dialog box, within the Autocorrect tab, uncheck the ‘Replace text as you type’ option.
Uncheck replace text as you type


Source: Excel AutoCorrect: A Complete Guide + Time Saving Examples
 
Upvote 0
Hi Dante,

Wow .. that actually worked! I don't understand why, but now it works fine. THANK YOU! I was going nuts trying to sort that one out :)

georgec32
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,753
Members
452,940
Latest member
rootytrip

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